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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a string with SQL from an existing query 1

Status
Not open for further replies.
May 30, 2001
17
0
0
US
Does anyone know how to store an existing querydef into a string in VBA? I am constantly referencing existing queries but change the queries themselves fairly frequently. I do this today by cutting and pasting the SQL from the query itself but would like to know how to do something similar to:

set strSQL = querydef ("SomeExistingQuery")

in a module.

Obviously the code above doesn't work (otherwise I wouldn't be posting now eh?).

Any suggestions? I frequently change queries and hardcoding the SQL to the string is not dynamic enough to support my needs.
 
Try:

strSQL = CurrentDb.QueryDefs("SomeExistingQuery").SQL




 
Worked like a charm. All I needed was the .sql at the end of the querydef. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top