Detect if user has not entered a criteria (1 Viewer)

David Ball

Registered User.
Local time
Tomorrow, 03:57
Joined
Aug 9, 2010
Messages
230
Hi,

I have a report that is fed by a parameter query. When a command button (Command23) is clicked a parameter box opens and the user enters a subsystem number. A report for that subsystem then opens.
I want to open the report with VBA and show a message if the user has failed to enter a subsystem number in the parameter box and just clicked OK.
The problem is I don’t know how to refer to the parameter box and detect if it has been left empty before clicking OK. I first tried to use IsNull in an If statement with Command23.Value, but now realize it is the value in the parameter box I am after, not the “value” of Command23.
How can I change my code to detect if the parameter box has not been filled out?

Private Sub Command23_Click()
If IsNull(Command23.Value) Then
MsgBox "You did not enter a Subsystem", vbOKOnly, "No Criteria Entered"
Else
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport
End If
End Sub

Thanks very much
David Ball
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:27
Joined
Aug 30, 2003
Messages
36,127
If you are using bracketed criteria, I don't think you can test for it. One of many reasons most of us use forms to gather user input.
 

Users who are viewing this thread

Top Bottom