470,863 Members | 1,402 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,863 developers. It's quick & easy.

Determining whether object exists

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
3 12704
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
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
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.

Similar topics

12 posts views Thread by Cliff Wells | last post: by
2 posts views Thread by Rob Mandeville | last post: by
3 posts views Thread by Gareth Tonnessen | last post: by
5 posts views Thread by Nathan Sokalski | last post: by
2 posts views Thread by Bob Sanderson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.