ACC2000: save WHERE clause to report via code

A

A Man

I have a report where I need to save the WHERE clause to it, so another
routine (which I did not write) can open the report and create a PDF
from it.

How do I do this via code?

Thank you.
 
A

A Man

I have a report where I need to save the WHERE clause to it, so another
routine (which I did not write) can open the report and create a PDF
from it.

How do I do this via code?

Thank you.
p.s. My report is not opened via the docmd.openreport command, hence the
need to save the WHERE information directly in the report itself.
 
D

Duane Hookom

You could create a table with fields to store your criteria values. Add this
single record table to your report's record source query and use the criteria
fields as criteria.
 
A

A Man

You could create a table with fields to store your criteria values. Add this
single record table to your report's record source query and use the criteria
fields as criteria.
Ok. I think I will change the report's recordsource property using a
different SQL statement for each customer, then call Leban's ConverToPDF
function.

How do I change the report's .Recordsource property in code?
 
D

Duane Hookom

If you really want to change the recordsource of a report, search google on
Access Reports "me.recordsource"
You will get tons of hits.
 
A

A Man

I tried the following but got an error:

sWhere = "[cus_no] = '" & sCustnum & "'"
Reports!DealerOrder2.Filter = sWhere
Reports!DealerOrder2.FilterOn = True


The error was '2451: The report name "DealerOrder2" you entered is
misspelled or refers to a report that isn't open or doesn't exist.'

So, I can open the report via Docmd.Openreport, but how do I close it
after I updated the properties .Filter and .Filteron?

Thank you.

p.s. Opening each report, for 800+ customers, is very time-consuming
also. It might take each report 1 minute to preview, times 800
customers, that's 800 minutes to process all customers. Which is why I
wanted a direct way, without using Docmd.Openreport, to update the
report properties directly.
 

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