command button validation

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 + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)

If bytChoice = vbOK 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top