J
Jon
I have set up a simple validation proceedure on the BeforeUpdate property as
follows:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.txtEmail) Or Me.txtEmail = "") And Me.EmailUpdates = -1 Then
MsgBox "Enter an email address.", vbInformation, "Data Validation"
Me.txtEmail.SetFocus
DoCmd.CancelEvent
Cancel = True
End If
End Sub
The form also has a several command buttons (e.g. save, next record,
previous record) which trigger the validation warning as expected. However
the OK or close button on the data validation Msgbox triggers a Runtime error
message; either 2105 'Can't go to specified record' or 2001 'You cancelled
previous operation', depending on the cmdButton
The go to next record proceedure is:
Sub Command186_Click()
On Error GoTo Err_Command186_Click
DoCmd.GoToRecord , , acNext
Exit_Command186_Click:
Exit Sub
Err_Command186_Click:
MsgBox Err.Description
Resume Exit_Command186_Click
The save record proceedure is:
Sub Command189_Click()
On Error GoTo Err_Command189_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_Command189_Click:
Exit Sub
Err_Command189_Click:
MsgBox Err.Description
Resume Exit_Command189_Click
Can anyone explain why this is happening and/or how to avoid it.
Many thanks
follows:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (IsNull(Me.txtEmail) Or Me.txtEmail = "") And Me.EmailUpdates = -1 Then
MsgBox "Enter an email address.", vbInformation, "Data Validation"
Me.txtEmail.SetFocus
DoCmd.CancelEvent
Cancel = True
End If
End Sub
The form also has a several command buttons (e.g. save, next record,
previous record) which trigger the validation warning as expected. However
the OK or close button on the data validation Msgbox triggers a Runtime error
message; either 2105 'Can't go to specified record' or 2001 'You cancelled
previous operation', depending on the cmdButton
The go to next record proceedure is:
Sub Command186_Click()
On Error GoTo Err_Command186_Click
DoCmd.GoToRecord , , acNext
Exit_Command186_Click:
Exit Sub
Err_Command186_Click:
MsgBox Err.Description
Resume Exit_Command186_Click
The save record proceedure is:
Sub Command189_Click()
On Error GoTo Err_Command189_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_Command189_Click:
Exit Sub
Err_Command189_Click:
MsgBox Err.Description
Resume Exit_Command189_Click
Can anyone explain why this is happening and/or how to avoid it.
Many thanks