Preview reports for selected records

  • Thread starter Thread starter Tia
  • Start date Start date
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.
 
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.
 
Back
Top