473,224 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

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 13564
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Cliff Wells | last post by:
Hi, I'm writing an application that needs to know if an Internet connection is available. Basically, I want to have something similar to what a lot of email clients have, where the app can work...
10
by: CJM | last post by:
I have a bit of code which involves some looping... In each iteration, we retrieve a string value... I want to build a list of DISTINCT (in the SQL sense) string values. Our example strings...
2
by: Rob Mandeville | last post by:
I need to open a file, and determine if: 1: I actually opened it 2: I couldn't open it because it doesn't exist, or 3: I couldn't open it for other reasons, such as file permissions. I'm...
3
by: Gareth Tonnessen | last post by:
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?...
5
by: Nathan Sokalski | last post by:
I have a DataList that I was having trouble getting the events for. After a bit of help, I realized that I needed to put the databinding inside an If Not IsPostBack() condition. Although this fixed...
4
by: ug26jhw | last post by:
Is there any way to determine whether an element in a document exists. I have some code like this where the variable i changes: if(document.getElementById('pref'+i).innerHTML... When it...
2
by: Bob Sanderson | last post by:
I need to execute an IF statement based on whether or not a file exists in a given folder. If the file is in the folder, do A, if it's not, do B. Is there a PHP statement that will determine if the...
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
2
by: BobLewiston | last post by:
Could someone please give me the simplest possible C# code snippets / SQL queries to determine whether: * a given SQL database exists, * a given existing SQL database is accessible, and * a...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.