QueryDef to change Criteria of a Saved Query

I

Ian

Does anyone know how to change the criteria filter of a
save query using DAO QueryDef. An Example would be very
helpful.

Thanks

Ian
..
 
S

Sandra Daigle

You can modify the entire SQL string as in the example that follows but to
change the Where clause you would have to parse it out separately and then
rebuild the entire SQL string with the new criteria.

dim qdf as dao.querydef
dim db as dao.database
set qdf=db.querydefs("MyQuery")
with qdf
.sql="Select * From tblMyTable Where MyID>3"
.close
end with
set qdf=nothing
set db=nothing
 
M

Marshall Barton

Ian said:
Does anyone know how to change the criteria filter of a
save query using DAO QueryDef. An Example would be very
helpful.


A query is really an SQL statement (in the QueryDef's SQL
property). With that in mind, why bother (re)constructing
the QueryDef's SQL statement when, most likely, you can
apply the new SQL statement to whatever you want to use the
query for.

It's can get rather messy trying to parse out a query's
Where clause. It's much easier to add a new Where clause
to an unfiltered query.

I could be more specific if you explained more about what
you have and what you want to accomplish.
 

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