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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to use one parameter value for multiple reports

Status
Not open for further replies.

RoyE

Technical User
Jun 25, 2003
10
US
I have several reports in which I have used data from a query. In the "conditions" of my "System No" field I have set up [Enter System No] as the parameter value the user enters. I would like to simplify my effort in printing reports such that the error "you entered an expression that has no value" is not displayed when the system number does not exist in the table and I only have to enter the parameter once. There are 4 reports that I must run each time I do this.
 
Can you trap the Error such as:

If Err.Number = 2427 Then
Exit Sub
End If
OR
If Err.Number = 2427 Then
MsgBox "Custom Error Message"
Exit Sub
End If

I believe 2427 is the error you described...
 
What I would normally do is create a form to accept the parameter value. Then in your query the parameter would look something like this:
forms!YourFormName!YourTextBoxName

Furthermore, if you use a combobox on your form you can limit your users to System Nos that exist in your table. If you don't want to use a combo box then in your report's On No Data event you can place this code:

Private Sub Report_NoData(Cancel As Integer)
msgbox "No data exists for System No. " & Forms!YourFormName!YourTextBoxName & "." _
, vbOKOnly, "Report Error"
DoCmd.CancelEvent
End Sub


HTH,
Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top