acoutputreport question (1 Viewer)

Access9001

Registered User.
Local time
Today, 10:23
Joined
Feb 18, 2010
Messages
268
DoCmd.OutputTo acOutputReport, "Report_Name", acFormatSNP, "C:\somepath\filename.snp"

The line above is outputting a snapshot, but the report is based on a query that depends on user input. That is to say, when I try to run this, it'll prompt me to enter in a value for the variable "Input" so that it'll churn out the rest of the report.

How can I add that field in this code so that I can specify what I want "Input" to be when this line runs? Thanks.
 

KenHigg

Registered User
Local time
Today, 13:23
Joined
Jun 9, 2004
Messages
13,327
One way is to put a parameter in the report query that prompts the user.
 

Access9001

Registered User.
Local time
Today, 10:23
Joined
Feb 18, 2010
Messages
268
I have a parameter in the recordsource that the Report draws from, where it basically ends with: "Where field=[Input]"

I just want to be able to programatically/automatically pass in what I want [Input] to be when I output this report.
 

KenHigg

Registered User
Local time
Today, 13:23
Joined
Jun 9, 2004
Messages
13,327
In the query if you put your user prompt message in square brackets in the appropriate column it will put what ever the users enters as the criteria.
 

Access9001

Registered User.
Local time
Today, 10:23
Joined
Feb 18, 2010
Messages
268
I have the square brackets already -- but I don't want this to be a user-input execution. The query is dynamic, as I don't want to make a billion separate reports for exporting each type of what I need. I simply want to be able to pass in a value for the variable in the code.

I have an array + for-each loop that will be cycling through a variety of "Inputs" to pass into this outputto command, but I just need some way of actually doing it.
 

KenHigg

Registered User
Local time
Today, 13:23
Joined
Jun 9, 2004
Messages
13,327
Oh, I got it backwards. Hum....

One way would be to build the sql string with code and base the report that.
 

Access9001

Registered User.
Local time
Today, 10:23
Joined
Feb 18, 2010
Messages
268
Oh, I got it backwards. Hum....

One way would be to build the sql string with code and base the report that.

That might work -- how can I change the recordsource of the report dynamically?
 

KenHigg

Registered User
Local time
Today, 13:23
Joined
Jun 9, 2004
Messages
13,327
In the report on open event:

Me.RecordSource = mySQLString
 

Access9001

Registered User.
Local time
Today, 10:23
Joined
Feb 18, 2010
Messages
268
So if I put that line in the Open event, and I have a separate function that does the outputto command, how do I pass in that sql string?
 

KenHigg

Registered User
Local time
Today, 13:23
Joined
Jun 9, 2004
Messages
13,327
You build the sql string in the event module.
 

Users who are viewing this thread

Top Bottom