How do you keep user from exiting a bad record? 
Author Message
 How do you keep user from exiting a bad record?

I am trying to write a data verification routine.  I want it to be called
when ever a new record is updated or when ever the user navigates the
database using the data control.  I placed the folowing code on the
datacontrol:

How do I keep the user from exiting a bad record until the corrections are
made or the bad record deleted?

Maurice



Dim Sub22 As Variant
Dim sub23 As Variant
Dim Sub24 As Variant
Dim Sub25 As Variant
Dim Sub26 As Variant
Dim Sub27 As Variant
Dim Benthos As Variant
Dim VeggieSum As Variant
Dim V12, V13, V14, V15, V16, V17, V18, V19, V20, V21 As Variant
Dim theLake, theStation, theDate, theGear As String
Dim dupRS As Recordset, dupFilter As String 'recordset

theLake = dbcLake.Text
theStation = txtHabitat(0).Text
theDate = MaskEdcDate.Text
theGear = dbcGear.Text   '''''checking for blank bag size field

    If Len(theGear) = 0 Then
        MsgBox "Gear field can not be blank"
        Exit Sub
    End If
   '''''checking for blank waterbody field
    If Len(theLake) = 0 Then
        MsgBox "Waterbody field can not be blank"
        Exit Sub
    End If
   '''''checking for blank fiscal year field
    If Len(theStation) = 0 Then
        MsgBox "Station field can not be blank"
        Exit Sub
    End If
   '''''checking for blank bag size field
    If Len(theDate) = 0 Then
        MsgBox "End Date field can not be blank"
        Exit Sub
    End If

'''''''''''''''''''''''''''Verify substrate'''''''''''''''''''''''''''''
Sub22 = Val(txtHabitat(22).Text)
sub23 = Val(txtHabitat(23).Text)
Sub24 = Val(txtHabitat(24).Text)
Sub25 = Val(txtHabitat(25).Text)
Sub26 = Val(txtHabitat(26).Text)
Sub27 = Val(txtHabitat(27).Text)

Benthos = Sub22 + sub23 + Sub24 + Sub25 + Sub26 + Sub27
If Benthos <> 100 Then
    Beep
    MsgBox "Total percentage for all substrate types adds up to " & Benthos
& "%.  It must equal 100%!"
    txtHabitat(22).SetFocus
    Exit Sub
End If

 '''''''''''''''''''''''''End Substrate Quantification''''''''''''''''''
''''''''''''''''''Verify vegetation percentages'''''''''''''''''

V12 = Val(txtHabitat(12).Text)
V13 = Val(txtHabitat(13).Text)
V14 = Val(txtHabitat(14).Text)
V15 = Val(txtHabitat(15).Text)
V16 = Val(txtHabitat(16).Text)
V17 = Val(txtHabitat(17).Text)
V18 = Val(txtHabitat(18).Text)
V19 = Val(txtHabitat(19).Text)
V20 = Val(txtHabitat(20).Text)
V21 = Val(txtHabitat(21).Text)
VeggieSum = V12 + V13 + V14 + V15 + V16 + V17 + V18 + V19 + V20 + V21

If VeggieSum <> 100 Then
    Beep
    txtHabitat(12).SetFocus
    MsgBox "Total percentage for all vegetation types adds up to " &
VeggieSum & "%.  It must equal 100%!"
    Exit Sub
End If
'''''''''''''''''''''''''end vegetation verification'''''''''''''''

End Sub



Fri, 17 Aug 2001 03:00:00 GMT  
 How do you keep user from exiting a bad record?
I am trying to write a data verification routine.  I want it to be called
when ever a new record is updated or when ever the user navigates the
database using the data control.  I placed the folowing code on the
datacontrol:

How do I keep the user from exiting a bad record until the corrections are
made or the bad record deleted?

Maurice



Dim Sub22 As Variant
Dim sub23 As Variant
Dim Sub24 As Variant
Dim Sub25 As Variant
Dim Sub26 As Variant
Dim Sub27 As Variant
Dim Benthos As Variant
Dim VeggieSum As Variant
Dim V12, V13, V14, V15, V16, V17, V18, V19, V20, V21 As Variant
Dim theLake, theStation, theDate, theGear As String
Dim dupRS As Recordset, dupFilter As String 'recordset

theLake = dbcLake.Text
theStation = txtHabitat(0).Text
theDate = MaskEdcDate.Text
theGear = dbcGear.Text   '''''checking for blank bag size field

    If Len(theGear) = 0 Then
        MsgBox "Gear field can not be blank"
        Exit Sub
    End If
   '''''checking for blank waterbody field
    If Len(theLake) = 0 Then
        MsgBox "Waterbody field can not be blank"
        Exit Sub
    End If
   '''''checking for blank fiscal year field
    If Len(theStation) = 0 Then
        MsgBox "Station field can not be blank"
        Exit Sub
    End If
   '''''checking for blank bag size field
    If Len(theDate) = 0 Then
        MsgBox "End Date field can not be blank"
        Exit Sub
    End If

'''''''''''''''''''''''''''Verify substrate'''''''''''''''''''''''''''''
Sub22 = Val(txtHabitat(22).Text)
sub23 = Val(txtHabitat(23).Text)
Sub24 = Val(txtHabitat(24).Text)
Sub25 = Val(txtHabitat(25).Text)
Sub26 = Val(txtHabitat(26).Text)
Sub27 = Val(txtHabitat(27).Text)

Benthos = Sub22 + sub23 + Sub24 + Sub25 + Sub26 + Sub27
If Benthos <> 100 Then
    Beep
    MsgBox "Total percentage for all substrate types adds up to " & Benthos
& "%.  It must equal 100%!"
    txtHabitat(22).SetFocus
    Exit Sub
End If

'''''''''''''''''''''''''End Substrate Quantification''''''''''''''''''
''''''''''''''''''Verify vegetation percentages'''''''''''''''''

V12 = Val(txtHabitat(12).Text)
V13 = Val(txtHabitat(13).Text)
V14 = Val(txtHabitat(14).Text)
V15 = Val(txtHabitat(15).Text)
V16 = Val(txtHabitat(16).Text)
V17 = Val(txtHabitat(17).Text)
V18 = Val(txtHabitat(18).Text)
V19 = Val(txtHabitat(19).Text)
V20 = Val(txtHabitat(20).Text)
V21 = Val(txtHabitat(21).Text)
VeggieSum = V12 + V13 + V14 + V15 + V16 + V17 + V18 + V19 + V20 + V21

If VeggieSum <> 100 Then
    Beep
    txtHabitat(12).SetFocus
    MsgBox "Total percentage for all vegetation types adds up to " &
VeggieSum & "%.  It must equal 100%!"
    Exit Sub
End If
'''''''''''''''''''''''''end vegetation verification'''''''''''''''

End Sub



Fri, 17 Aug 2001 03:00:00 GMT  
 How do you keep user from exiting a bad record?
The Data Control has a validate method such as:

Sub Data1_Validate(Action as Integer, Save As Integer)

The *action* argument describes the action that triggered the validate event.
1=MoveFirst, 2=PreviousRecord, 11=Form Unload, etc.

You can set Save to false and the data will not be saved to the database.
------------------------------------------------
You can also use
BeginTrans, CommitTrans and Rollback to control processing of data (in
conjunction with data checking).

Hope this helps a little.



Sat, 18 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Keep Track of Excluded Users for each Record

2. Keep Track of Excluded Users for each record

3. Bound Controls: bad,bad,bad

4. RDO bad, bad, bad

5. RDO bad, bad, bad

6. BAD DLL calling conventions - What am I doing wrong

7. How to exit AND keep files open?

8. While Doing Loop Goto Exit and Do Wend

9. Keep focus unless Exit button clicked?

10. Keeping variables after exit

11. vbScript - keeping open an InputBox after input has been done

12. How to Append Bad Records to another table

 

 
Powered by phpBB® Forum Software