A
alex
I have the following code in an Access Form:
It works well; however, if a user enters the form and hits the
command
button below (54) (without entering any info) the command triggers
the
Msgbox event, without checking form/table validation.
Conversely, if a user enters the form and types even a keystroke,
then
hits the command button, Access knows to kick in the validation that
I've set up and instructs the user to populate required fields.
Question: how to make the code below check for form/table validation
even if the user types nothing into the form?
Thanks for your help ~ alex
Private Sub Command54_Click()
On Error GoTo Err_Command54_Click
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
strMessage = "RECORD SAVED! ARE YOU FINISHED?"
intOptions = vbQuestion + vbYesNo
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbYes Then
DoCmd.PrintOut
DoCmd.Close
Else
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl ("RECEIPT")
End If
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub
It works well; however, if a user enters the form and hits the
command
button below (54) (without entering any info) the command triggers
the
Msgbox event, without checking form/table validation.
Conversely, if a user enters the form and types even a keystroke,
then
hits the command button, Access knows to kick in the validation that
I've set up and instructs the user to populate required fields.
Question: how to make the code below check for form/table validation
even if the user types nothing into the form?
Thanks for your help ~ alex
Private Sub Command54_Click()
On Error GoTo Err_Command54_Click
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
strMessage = "RECORD SAVED! ARE YOU FINISHED?"
intOptions = vbQuestion + vbYesNo
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbYes Then
DoCmd.PrintOut
DoCmd.Close
Else
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl ("RECEIPT")
End If
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub