
Testing for a queries existence
There are a number of ways: the easiest is to just by default delete any
existing query:
On error resume next
db.querydefs.detete "qryMyQuery"
On Error GoTo ... 'restore any error handler.
db.createquerydef ("qryMyQuery")
You should also add the deletion code to any exitr code in your procedure
and direct any error handler ther so that even when the user generates an
error the dynamic query will be deleted before the query is exited.
You could also create an unnamed query
db.createquerydef ("",strSQL) which will not persist after the procedure
and thus you do not have to worry about deleting it.
You could also loop through the querydefs checking for the queryname or trap
the error by trying to set the new querydef ti the same name, but the above
is simplest and most effecient.
Hope this helps,
GR
Quote:
>I am running code which creates, uses and then deletes a query.
>Occassionally a user will cause an error which kicks them out of the
routine
>after the create but before the delete. When they get back in and try to
>rerun the code it gives the "query already exists" error. What statement
>will test for the existence of the query so I can delete it before I call
>the create command. I tried "If isloaded" and "if isnull" but neither
>worked.
>thanks in advance.
>David DeMeglio