Generate Report Based Upon Selection in Listbox?

woodman650

Always confused.
Local time
Today, 15:42
Joined
Jan 22, 2005
Messages
55
Hey all,
Happy Holidays! I just had a question regarding reports...

I have a listbox containing ID numbers for invoices... I wondered if there was a way to click on a Listbox entry, hit a command button and have a report template for my invoices open up displaying the data for invoice ID selected in the listbox? (hope that made sense) haha.

I presume it might be doable in a macro... but I'm not sure. thanks!
 
Sure; look at the wherecondition argument of DoCmd.OpenReport (or a macro, though I don't recommend them).
 
paul, you are quick on the responses tonight... thank you =)

Could you elaborate a little bit more on this?

I just don't know where to take the code.
I have to specify that the report displays the information associated with the ID of the value selected from the listbox... no clue how to turn this into code. =(
 
Last edited:
Did you look in VBA Help for OpenReport, specifically at the wherecondition argument? I believe there are examples there (and here).
 
Yeah, I found some examples... but I don't know how to relate it to a selected value in a listbox.

strWhere = "[InvoiceID] = " & Me.ListboxName.[InvoiceID]
DoCmd.OpenReport "InvoiceReport", acViewPreview, , strWhere
 
Presuming the invoice id is a numeric value (and the listbox not multiselect), that's close. Try:

strWhere = "[InvoiceID] = " & Me.ListboxName

That also presumes that the bound column of the listbox is the id, if there are multiple columns.
 
If the bound column is the third column then
strWhere = "[invoiceID] = " & Me.ListboxName.column(2)
as the column numbers are zero based
John
 

Users who are viewing this thread

Back
Top Bottom