Preview reports for selected records

T

Tia

I am trying to create a command button that takes the information from a
multi-select list box and opens up the report for only those records selected
from the list box.

How can I accomplish this without the command button opening the print
preview of the report for all records? Thanks.
 
F

fredg

I am trying to create a command button that takes the information from a
multi-select list box and opens up the report for only those records selected
from the list box.

How can I accomplish this without the command button opening the print
preview of the report for all records? Thanks.

The easiest way to do something like this is to add a check box field
to the underlying table. If a query is the record source for the form,
add this check box field to the query. Then include this check box in
the form you are using.
Then simply place a check in each record you wish to report on.

Code your command button on the form:
DoCmd.OpenReport "ReportName", acViewPreview, , "[CheckBoxField] =
-1")

When finished with the report, you can run an Update query to reset
all of the check boxes to unchecked.
Using another command button:

CurrentDb.Execute "Update MyTable Set MyTable.CheckBoxField] =
0;",dbFailOnError

Change MyTable and CheckBoxField to whatever your actual table and
field names are.
 

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

Similar Threads


Top