Queries for a report

K

keameyer

I have a database that I would like the user to select an item from a
dropdown list and then run a query on a different table to generate a
report for the user, does anyone know how I can do this?
 
N

Nikos Yannacopoulos

While this can easily be done with a little VBA code, your data design
is questionable; your post implies that you have several tables with the
same design (same fields), but holding data for different entities? For
instance, you have different Sales tables, each holding data for a
different region?
If that is indeed the case, then your design is not correct: you are
effectively storing data implicitly in the table names, as the only
piece of information specifying which region a sale belongs to, is the
table it is stored in. This is bound to get you into trouble, your
current question being just the tip of the iceberg. The right way to do
it is store all data in a single table, with an extra field for region;
then all you need to do is filter on this field in a query.
In case I have misinterpreted your question, please clarify. If I have
not, please elaborate on your current design for more specific help if
required.

HTH,
Nikos
 
K

Kate Williams

keameyer said:
I have a database that I would like the user to select an item from a
dropdown list and then run a query on a different table to generate a
report for the user, does anyone know how I can do this?

You'll need to set up the criteria for the query so it looks in the
control on the form:

like [Forms]![Form Name]![Control Name].

Base the report on the query.

Put a button on the form and add an event procedure to "on click"

DoCmd.OpenReport "Report Name", acviewpreview

N.B. if you use acviewnormal the report will not open and instead just
go straight to the default printer.

Kate
 
Top