Passthrough query variable

G

Guest

on 12/10/04 Duane provided an answer for having a passthrough query run with
a variable:

You can modify the SQL property of the saved p-t query with code like:
Dim strSQL as String
strSQL = "Select Group From GroupTable where Group In ('" & var1 & "')"
Currentdb.QueryDefs("YourPTNameHere").SQL = strSQL

--

Could you please back up one step? Where does this code go? Can it just be
set at the beginning of a module to declare database properties? Do I have
to create a new function? If so, how would I call that function?

Is this a way to get a prompt to enter variables as the p-t starts up?

Thanks.
ann
 
D

Duane Hookom

Where do you set the value of var1? Assuming you have a form with
Text Box for the user to enter a Group value:
Name: txtGroup
Control Source:
Command button to open the report. Add code to the click button that
modifies the
Dim strSQL as String
strSQL = "Select Group From GroupTable where Group In ('" & Me.txtGroup &
"')"
Currentdb.QueryDefs("YourPTNameHere").SQL = strSQL
 

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