Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catching the "cancel" button request on the input box of a query

Status
Not open for further replies.

kevink

Programmer
Nov 23, 1999
53
0
0
IE
How can I detect if the user has hit &quot;cancel&quot; on the input box of a query?<br>
<br>
The query is designed to prompt the user for the criteria. I then requery the form if they want to do another search (me.requery). The problem then occurs if they press &quot;cancel&quot; - it causes an error in the code - so I'd really like to catch this and exit gracefully.<br>
<br>
In the same vein is there anyway I can find if the query results in a null value and display a message/input box with a message?<br>
<br>
Thanks,<br>
<br>
Kevin.
 
On the second question do you mean if there is no data in the report? There is an On No Data event, example:<br>
<br>
Private Sub Report_NoData(Cancel as integer)<br>
MsgBox &quot;There is no data that matches the parameters...&quot;<br>
Cancel = True<br>
End Sub
 
On the first question try the standard input box, it gives you OK & Cancel buttons by default:<br>
<br>
Dim strParm As String<br>
strParm = InputBox(&quot;This is the prompt&quot;)<br>
<br>
I<br>
<br>

 
Use error handling. Trap the specific error with a specific message.
 
Use error handling. Trap the specific error with a specific message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top