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!

Calling a Query

Status
Not open for further replies.

SAXMAN99

Technical User
Jun 10, 2003
11
0
0
CA
Hello, I have tried to call a query so i can dynamically change the filtering on it. but i do not know how to call a query. i have tried the Query!queryname, much like one might call a form. form!frmname. but that hasnt worked, does anyone know how?
thanks in advance
Saxman99
 
Hi Saxman:

You can programmatically change the query with the following

Dim qdf As DAO.QueryDef
dim sql as string

Set qdf = CurrentDb.QueryDefs(QueryDefName)
sql = qdf.sql 'preserving original
qdf.sql = "Select..." 'updating query

qdf.close
set qdf = nothing

Bear in mind,, this will change the query's content's permanently. If you need to restore the original query, then make sure you copy the original sql into a string.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top