Opening Report based on ListBox selection

stanbridge

New member
Local time
Today, 05:01
Joined
May 10, 2011
Messages
3
Hi all,

I am relatively new to Access (Access 2007), and am having a bit of trouble fumbling my way through the following issue...

In my form(frm_Customers2) I have a ListBox(Customer_Invoice_List) that contains a series of invoices, each with a unique ID (although the ID isn't a visible column).

When a user double-clicks on one of the entries in the ListBox, I want it to open my Report(rpt_Invoices), displaying only records where rpt_Invoices.Invoice_ID = Customer_Invoice_List.Invoice_ID.

In all of my attempts, I keep getting prompted to enter the ID. I suspect I am not pointing to the items I want properly.

Can somebody give me some noob instructions as to how I would accomplish the task above?

Any help is very much appreciated!


Cheers,

Chris
 
Use the Where argument of the OpenReport command.

Please post the code line you are using to open the report now.
 
I have been trying the WHERE command (but without success). Here's my latest attempt...

[Reports]![rpt_SelectedInvoice]![MasterInvoiceSelection]=[Forms]![frm_Customers2]![Customer_Invoice_List]

I then tried...

[Reports]![rpt_SelectedInvoice].Invoice_ID=[Forms]![frm_Customers2]![Customer_Invoice_List].Invoice_ID



Cheers
 
Last edited:
The WhereCondition argument is exactly like the Where in a query without the keyword (Where).
http://msdn.microsoft.com/en-us/library/bb238032(v=office.12).aspx

It is a string so must be in quotes.
Code:
"Invoice_ID=[Forms]![frm_Customers2]![Customer_Invoice_List]"

(This assumes the InvoiceID is the BoundColumn of the ListBox)

It is also often written by concatenating the value into the string.
Assuming InvoiceID is a number:
Code:
"Invoice_ID=" & Me![Customer_Invoice_List]
 

Users who are viewing this thread

Back
Top Bottom