Allen Browne's Multi-Select Tip

I

iamnu

http://allenbrowne.com/ser-50.html

The above link is an excellent tip which explains how to use a multi-
select list box to select several items at once, and open a report
limited to those items.

I have this code working on several of my reports, but my "PREFERENCE"
would be to run the Report first, and get necessary parameters from
the Form.

I'm not having any luck in doing this, and in particular, I can't see
how to get the value of "strWhere" (the WhereCondition) into my
report, after the fact. I have passed the exact same information via
a text box to my report, but then when I put that value (Forms!box1!
strVal) into the Criteria for the DirectoryID, it doesn't work.

1. I'd like to know why Mr. Browne decided to print the report by
actually opening a Form. I ask this, because it doesn't seem
intuitive to open a Form, when you really want to see a Report.

2. I'd like a suggestion on how to get the value of "strWhere" into
my SQL statement so that it will work.

Thanks for your help...
Bernie
 
A

Allen Browne

You could run the code in the Open event of the report. In that event, you
need to open the form in *dialog* mode (which pauses the Report_Open event),
and set the report's Filter property ot the value of strWhere (remembering
to set its FilterOn to True as well.)

If you find that more intuitive than opening the report from the form, go
right ahead. Professional developers rarely let users anywhere near the
Database window, so all reports get opened from the interface (such as a
form.) I generally use one form to open dozens of reports, and reuse the
same filter boxes for many of them. It would be possible to maintain the
Report_Open event of each report in its own module, but I find it much
easier to maintain a single form that opens dozens of reports, i.e. the code
is all in one place.
 
I

iamnu

You could run the code in the Open event of the report. In that event, you
need to open the form in *dialog* mode (which pauses the Report_Open event),
and set the report's Filter property ot the value of strWhere (remembering
to set its FilterOn to True as well.)

If you find that more intuitive than opening the report from the form, go
right ahead. Professional developers rarely let users anywhere near the
Database window, so all reports get opened from the interface (such as a
form.) I generally use one form to open dozens of reports, and reuse the
same filter boxes for many of them. It would be possible to maintain the
Report_Open event of each report in its own module, but I find it much
easier to maintain a single form that opens dozens of reports, i.e. the code
is all in one place.

Thanks for the reply.

You've made me rethink what I'm doing, as the idea of using a form
that is opened with the database, something like Northwind's
Switchboard, just might make more sense. Thanks for the suggestion.

However, I'd still like to know how to accomplish my original
objective, if I choose to go that way.

"In that event, you need to open the form in *dialog* mode (which
pauses the Report_Open event), and set the report's Filter property ot
the value of strWhere (remembering to set its FilterOn to True as
well.) "

What is *Dialog* mode? I don't see that in the OpenForm Method Help
screen.
How do I set the report's Filter property of the value of strWhere,
and how do I set it's FilterOn to True?

Thanks again,
Bernie
 
D

Duane Hookom

I find it very intuitive to open a form to make selections and set criteria
and then open a report based on these choices. To me it's like check a map to
figure out where you are going before you get in the car and actually start
driving.

I suppose you could open the form in acDialog mode from the On Open event of
the report. Then allow the user to make selections and set the Filter
property of the report and hide the form.
 
A

Allen Browne

Answers in-line.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

iamnu said:
"In that event, you need to open the form in *dialog* mode (which
pauses the Report_Open event), and set the report's Filter property
to the value of strWhere (remembering to set its FilterOn to True as
well.) "

What is *Dialog* mode?

DoCmd.OpenForm "Form1", WindowMode:=acDialog
How do I set the report's Filter property of the value of strWhere,

Reports!Report1.Filter = strWhere
and how do I set it's FilterOn to True?

Reports!Report1.FilterOn = True
 

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