If IsNull Check Number Stop Code, What is wrong with this code ?

D

Dave Elliott

I want it to stop the code if there is no check number .

On Error GoTo Err_Command89_Click

Dim stDocName As String
If IsNull(Me.ChkNo) Then
MsgBox "Check Number Needed Please"
Cancel = True

stDocName = "Checks"
Forms!blankchecks.Visible = False
DoCmd.OpenReport stDocName, acNormal

Exit_Command89_Click:
Exit Sub

Err_Command89_Click:
MsgBox Err.Description
Resume Exit_Command89_Click
End If
 
W

Wayne Morgan

This appears to be in a Click event of a control, possibly a button. Cancel
is not a built in option in the Click event. You may just want to leave the
subroutine at this point instead.

Exit Sub

Also, the End If probably belongs after the Cancel statement (changed to
Exit Sub), not at the bottom where it is now.

Private Sub Command89_Click()

On Error GoTo Err_Command89_Click
Dim stDocName As String
If IsNull(Me.ChkNo) Then
MsgBox "Check Number Needed Please.", vbOkOnly + vbInformation
Exit Sub
End If

stDocName = "Checks"
Forms!blankchecks.Visible = False
DoCmd.OpenReport stDocName, acNormal

Exit_Command89_Click:
Exit Sub

Err_Command89_Click:
MsgBox Err.Description
Resume Exit_Command89_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