Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question: Opening a Rpt from Form (report driven by parameter Query)

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
0
0
US
Have a report that is driven by a parameter query.

I would like to print it from a command button on a form but don't want the user to have to key in the parameter because it is a nonsensical number that the underlying code already knows.

Is it possible to pass the parameter to the Query that drives the report from VBA code?

(looking at the OpenReport "help" it appears that something can be passed as sql? does this mean that i can code the same sql that is in the parameter query here ?)

something like the following ? note, the actual value i need to pass to the query is in a global string defined as "SAVEKEY"...... it has the argument that the query needs to match on ~ i figured i could pass it as follows but it does not work ~ !

DoCmd.OpenReport stDocName, acPreview, , [ProductInfo.KEY2] = & SAVEKEY


The "where" statement in the parameter query that underlies the report reads :

Where (([ProductInfo.KEY2] = [KEY]));

KEY is the name of the parameter ~

Hope it is possible to do something like this ~ driving me nuts !

BTW, thanks in advance !
 
this question was answered in another Access forum

DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top