How do I use a list box to open a report based on a single record

A

Annie1904

I've created a form (as a menu) and on this form there is a button. When I
press this button it opens a list box. The list box is based on a query
which has selected customer id, first and last names from my database. I
also have a report which will provide me with specific details about each
customer.

I want to scroll down the list and click on the selected customer, and
automatically open the report showing that customer's details. I suspect I
need to create some macro or criteria in the query, but don't know how to do
this. Can anyone help me?
 
T

tina

is the report bound to the query? and is CustomerID the primary key of the
table? if yes to both, there are two ways to get what you're after:

make sure that the CustomerID is the bound column of the listbox.

Solution 1
open the query in design view. in the CustomerID column, add the criteria

[Forms]![MyForm]![MyListbox]

substitute the correct names of form and listbox, of course. save and close
the query. in form design view, create a macro attached to the command
button, with an OpenReport action that opens the report.

Solution 2
in the form's design view, create a macro attached to the command button,
with an OpenReport action and setting the Where Condition, as

[CustomerID] = [Forms]![MyForm]![MyListbox]

substitute the correct field name, form name, and listbox name, of course.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top