report based on multiselect list box A97

  • Thread starter Thread starter Brigitte P
  • Start date Start date
B

Brigitte P

I have my query and my listbox running fine. The user selects several
records (either by holding shift or ctr key) in the list box which then
passes on to my query which is the basis for the report. However, to get the
whole thing update when a new selection is made, I have the user to (via
buttons on the selection form) first run the query, then print the report,
then clear the form (requery button). I know there must be a better way, but
help just talks about requery, which seems to reset the listbox, but doesn't
reset the query. How can I activate the query once a new selection is made
and before the report is run without having the user to run the query?
I put requery in many possible forms on the Open Event on the report, but
nothing happens, and I kind of understand why. I then put the requery
command in the button that activates the report, again no luck.
What I need is that the query gets activated after the user made the
selection, but before the report is printed. I don't know how to do this.
Please help.
Brigitte P.
 
The simplest solution is probably to add a button to your form.
The Click event of the button performs the OpenReport.
Use the WhereCondition of the OpenReport action to limit your report.

To construct the string for the WhereCondition, loop through the
ItemsSelected collection of the list box. Concatenate them with a comma
between, and use the result with the IN operator. The string will end up
looking like this:
SomeField IN ("Jane", "Fred", "Barney")
 
Allen, this is a little over my head but it got me in the right direction. I
just copied the code from the run query button (created with the wizzard)
into the code of the button that will run my report (also created with the
wizzard), obviously modifying the query before I run the report. It works
fine with the one button, and the user doesn't see the query running. I got
the code for the multiselect query from the Access help, and it does use the
Where. Thanks for jumpstarting my brain.
Brigitte P.
 
Back
Top