josephbupe
Registered User.
- Local time
- Tomorrow, 00:40
- Joined
- Jan 31, 2008
- Messages
- 247
I am writing a small database using MS Access 2007. I have in it a function for running queries and printing reports. Printing works just fine if any one of the multiple query criteria is give.
I also want to trap errors and present a message if the user clicks the "Print" button without a query criteria. At the moment I only get a run-time syntax error message which has a "debug" button for accessing the entire code. I want a message that will say "Sorry, there was no search criteria".
This is the code for printing:
I thank you.
Joseph
I also want to trap errors and present a message if the user clicks the "Print" button without a query criteria. At the moment I only get a run-time syntax error message which has a "debug" button for accessing the entire code. I want a message that will say "Sorry, there was no search criteria".
This is the code for printing:
Code:
Private Sub cmdPrint_Click()
Dim varWhere As Variant
varWhere = BuildFilter
' Update the record source
Me.RecordSource = "SELECT * FROM q_Vehicles " & varWhere
' Requery the form
Me.Requery
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = "" Else
'The WHERE clause does NOT need the word "WHERE"
' strip off "WHERE " in the filter
varWhere = Mid(varWhere, 7) End If DoCmd.OpenReport "rpt_Vehicles", acPreview, , varWhere
End Sub
I thank you.
Joseph
Last edited: