Populating the Criteria section of a query.?

P

PAkerly

Hello,
I have a report that is based on a query.

If I run the report with no Criteria I get 25 reports.

I want to run the query based on criteria, then run the reports
getting 5 reports.

The query has a field called clientID and those are A01, A02, A03,
B010, B015

I want to put a button on my form that when clicked will run that
query And in the Criteria for ClientID will populate it.
I want it to loop through until it finds all the A01's, save that
query and then run the report based on that query.
I then want it to loop through all the A02's, save the query, run the
report. etc...

How would I accomplish this?
 
R

Rick Brandt

Hello,
I have a report that is based on a query.

If I run the report with no Criteria I get 25 reports.

I want to run the query based on criteria, then run the reports getting
5 reports.

The query has a field called clientID and those are A01, A02, A03, B010,
B015

I want to put a button on my form that when clicked will run that query
And in the Criteria for ClientID will populate it. I want it to loop
through until it finds all the A01's, save that query and then run the
report based on that query. I then want it to loop through all the
A02's, save the query, run the report. etc...

How would I accomplish this?

You're making this way too difficult. The OpenReport method can pass a
temporary WHERE clause so all you need to do is design the report to show
all records and then have the code behind your button apply the desired
filter.

DoCmd.OpenReport "ReportName", acViewPreview,,"ClientID IN('A01', 'A02',
'A03', 'B010', 'B015')"
 
P

PAkerly

You're making this way too difficult.  The OpenReport method can pass a
temporary WHERE clause so all you need to do is design the report to show
all records and then have the code behind your button apply the desired
filter.

DoCmd.OpenReport "ReportName", acViewPreview,,"ClientID IN('A01', 'A02',
'A03', 'B010', 'B015')"

Great thanks...
Will this work if I dont know all the client ID's? Right now there are
5, but there might be more in the future and Is there a way to just
loop through each one saving the report for each ID?
 

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