G
GPO
Access 2000.
I have a form with six fields. All fields are mandatory (required). I have
written the following code to warn people that if they have left any fields
blank, the record will not be saved. It is triggered by a click event on a
hyperlink label which takes them back to a main form. It works except that
when people complete data in a control and then click directly on the
hyperlink, MS Access seems to see the last field completed, as being
incomplete. It is as if an update event has not fired for that control.
Private Sub lblBack_Click()
On Error GoTo ErrorHandler
If IsNull(Me.cboDogBreed.Value) Or _
IsNull(Me.cboPetFood.Value) Or _
IsNull(Me.txtComments.Value) Or _
IsNull(Me.txtDateLoaded.Value) Or _
IsNull(Me.txtVisit_ID.Value) Or _
IsNull(Me.txtDogUniqueKey.Value) Then
If MsgBox("All fields must be complete." & vbCrLf & _
"Click [Retry] to re-enter, or [Cancel] to exit without saving
data.", _
vbRetryCancel, "Warning") = vbRetry Then
DoCmd.CancelEvent
Else
DoCmd.Close acForm, "frmDogDataEntry", acSaveYes
Forms.frmViewAnimals.sfrmViewDogs.Requery
End If
Else
DoCmd.Close acForm, "frmDogDataEntry", acSaveYes
Forms.frmViewAnimals.sfrmViewDogs.Requery
End If
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
Any ideas?
Cheers
GPO
I have a form with six fields. All fields are mandatory (required). I have
written the following code to warn people that if they have left any fields
blank, the record will not be saved. It is triggered by a click event on a
hyperlink label which takes them back to a main form. It works except that
when people complete data in a control and then click directly on the
hyperlink, MS Access seems to see the last field completed, as being
incomplete. It is as if an update event has not fired for that control.
Private Sub lblBack_Click()
On Error GoTo ErrorHandler
If IsNull(Me.cboDogBreed.Value) Or _
IsNull(Me.cboPetFood.Value) Or _
IsNull(Me.txtComments.Value) Or _
IsNull(Me.txtDateLoaded.Value) Or _
IsNull(Me.txtVisit_ID.Value) Or _
IsNull(Me.txtDogUniqueKey.Value) Then
If MsgBox("All fields must be complete." & vbCrLf & _
"Click [Retry] to re-enter, or [Cancel] to exit without saving
data.", _
vbRetryCancel, "Warning") = vbRetry Then
DoCmd.CancelEvent
Else
DoCmd.Close acForm, "frmDogDataEntry", acSaveYes
Forms.frmViewAnimals.sfrmViewDogs.Requery
End If
Else
DoCmd.Close acForm, "frmDogDataEntry", acSaveYes
Forms.frmViewAnimals.sfrmViewDogs.Requery
End If
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
Any ideas?
Cheers
GPO