A
alex
Suppress MsgBox
Hello,
Using Access ’03…
I have the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'code to see if someone is trying to save a record with no hours
If IsNull(Hours) Then
MsgBox "You are trying to save a record with NO Hours!" _
& vbNewLine & _
"" _
& vbNewLine & _
"Use the undo button to cancel this record."
DoCmd.CancelEvent
Me.Hours.SetFocus
Else: Exit Sub
End If
End Sub
When this code fires, I get two message boxes—my message, and a
message from Access saying: You canceled the previous operation.
I like to suppress the latter message box. Is this possible?
I did modify the code above and changed DoCmd.CancelEvent to Me.Undo…
this works well (no second msgbox), but as you know it wipes out
"everything."
I basically want the user to enter hours in the hours textbox or undo
the record.
I do have data integrity rules on the table (for the hours field), but
as you know, the error that Access provides is not very eloquent.
Thanks,
alex
Hello,
Using Access ’03…
I have the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'code to see if someone is trying to save a record with no hours
If IsNull(Hours) Then
MsgBox "You are trying to save a record with NO Hours!" _
& vbNewLine & _
"" _
& vbNewLine & _
"Use the undo button to cancel this record."
DoCmd.CancelEvent
Me.Hours.SetFocus
Else: Exit Sub
End If
End Sub
When this code fires, I get two message boxes—my message, and a
message from Access saying: You canceled the previous operation.
I like to suppress the latter message box. Is this possible?
I did modify the code above and changed DoCmd.CancelEvent to Me.Undo…
this works well (no second msgbox), but as you know it wipes out
"everything."
I basically want the user to enter hours in the hours textbox or undo
the record.
I do have data integrity rules on the table (for the hours field), but
as you know, the error that Access provides is not very eloquent.
Thanks,
alex