Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QueryDef to change Criteria of a Saved Query

10 views
Skip to first unread message

Ian

unread,
Jun 30, 2004, 10:34:37 AM6/30/04
to

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

Thanks

Ian
.


Sandra Daigle

unread,
Jun 30, 2004, 11:30:12 AM6/30/04
to
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

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Marshall Barton

unread,
Jun 30, 2004, 11:37:53 AM6/30/04
to
Ian wrote:
>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.
--
Marsh
MVP [MS Access]

0 new messages