By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,490 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,490 IT Pros & Developers. It's quick & easy.

Determining whether object exists

P: n/a
I need to have a clean way to determine whether a query exists without trying
to open it and getting an error message. Is there a simple way to determine
whether an object exists in a database?
Remove obvious from e-mail address.
Gareth Tonnessen
Lu******@att.netNOJUNK
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 02 Apr 2004 20:00:19 GMT, lu******@aol.comNOJUNK (Gareth Tonnessen)
wrote:
I need to have a clean way to determine whether a query exists without trying
to open it and getting an error message. Is there a simple way to determine
whether an object exists in a database?
Remove obvious from e-mail address.
Gareth Tonnessen
Lu******@att.netNOJUNK


How about using IsObject? It will return True if the object is found,
a trappable error if not.

IsObject(CurrentDb.QueryDefs("qryName")

- Jim

Nov 12 '05 #2

P: n/a
Lookup the hidden system table MSysObjects to see if it has an entry of Type
5 (a query) with the Name you want:

If Not IsNull(DLookup("ID", "MSysObjects", _
"(Name = 'MyQuery') AND (Type = 5)")) Then

Alternatively, examine the QueryDefs collection.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Gareth Tonnessen" <lu******@aol.comNOJUNK> wrote in message
news:20***************************@mb-m05.aol.com...
I need to have a clean way to determine whether a query exists without trying to open it and getting an error message. Is there a simple way to determine whether an object exists in a database?
Remove obvious from e-mail address.
Gareth Tonnessen
Lu******@att.netNOJUNK

Nov 12 '05 #3

P: n/a
Thank you both for the responses. Now I even have alternative ways to
accomplish the task!
Remove obvious from e-mail address.
Gareth Tonnessen
Lu******@att.netNOJUNK
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.