QueryDef to change Criteria of a Saved Query

  • Thread starter Thread starter Ian
  • Start date Start date
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
..
 
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
 
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.
 
Back
Top