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

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
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
 
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
 
Back
Top