Sql Backend

C

CS

I have a query which is a sqlPass through query. I want the query to take a
parameter from a form. How could i do this? An example:

This is an Access query :

Select * from Location where Location.Id = forms!frmloc!Id

I want the above query to be written as a pass thro sql query.

Please help

thanks
 
R

Rick Brandt

CS said:
I have a query which is a sqlPass through query. I want the query to
take a parameter from a form. How could i do this? An example:

This is an Access query :

Select * from Location where Location.Id = forms!frmloc!Id

I want the above query to be written as a pass thro sql query.

Please help

thanks

You have to use code to change the SQL of the query...

CurrentDB.QueryDefs("QueryName").SQL = "Select * from Location where
Location.Id = " & forms!frmloc!Id

Notice how the form reference is outside the quotes. The SQL will end up
containing the value found at the form reference instead of the actual
string "forms!frmloc!Id".
 
Top