Print Report based on lstbox rowsource (1 Viewer)

JPR

Registered User.
Local time
Yesterday, 21:24
Joined
Jan 23, 2009
Messages
210
Hello,

I have a listbox on a form which is used to view data from different table. The listbox is populated by a combox and each query uses the combo as criteria.

I have added a cmd button that should print a report based on the list box row source but only works with one report.
Can someone help me so that I can get this code to work? Than you

Code:
If Me.lstsearch.RowSource = "qry1" Then
DoCmd.OpenReport "rpt1", acNormal, , strWhere

End If

If Me.lstsearch.RowSource = "qry2" Then
DoCmd.OpenReport "rpt2", acNormal, , strWhere

End If
 
A Select Case would be better.
If you can be consistent as to your naming, you could work out the report name from the rowsource?
No idea as to why only one report works. :(

Have you thought about walking your code? That is the first thing I do every time, if something does not work.
Often as I was testing it, before finding any issues.
 
how does the listbox get pupolated by the combo, show us the code.
 
Thank you.
Just realized that I had referred to a different query. Correct. I had to walk my code first!!!!
 

Users who are viewing this thread

Back
Top Bottom