473,405 Members | 2,445 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,405 software developers and data experts.

How do I figure out if a query already exists?

Basically, here's what's happening with the program. I have a table of
Customers and a table of Pets, with the latter containing a field
linking it to its customer of ownership. I have a form with all of the
personal information of the customers, and within it is a list box with
all of the pets in it. In the current design, it takes that
information from a query, but since every customer is different, the
query needs to change each time. So, I just delete and recreate the
query each time the form is loaded or the record is changed. In the
off-chance that the query is deleted between form loads, it'll give an
error when it tries to debug, and I figure a workaround on the error
probably isn't the best way to do it.
I guess it's two questions, then. 1) Is this the best way to do it,
and 2) How do I figure out if a query already exists and needs to be
deleted?

Jul 13 '06 #1
2 1704
On 12 Jul 2006 20:40:49 -0700, kk*******@gmail.com wrote:

I think you're doing something very wrong. The query can "look back"
at the form and select just the pets for the current customer:
select PetID, PetName from Pets
where CustomerID = Forms!MyForm!MyCustomerID

-Tom.

>Basically, here's what's happening with the program. I have a table of
Customers and a table of Pets, with the latter containing a field
linking it to its customer of ownership. I have a form with all of the
personal information of the customers, and within it is a list box with
all of the pets in it. In the current design, it takes that
information from a query, but since every customer is different, the
query needs to change each time. So, I just delete and recreate the
query each time the form is loaded or the record is changed. In the
off-chance that the query is deleted between form loads, it'll give an
error when it tries to debug, and I figure a workaround on the error
probably isn't the best way to do it.
I guess it's two questions, then. 1) Is this the best way to do it,
and 2) How do I figure out if a query already exists and needs to be
deleted?
Jul 13 '06 #2
DFS
kk*******@gmail.com wrote:
Basically, here's what's happening with the program. I have a table
of Customers and a table of Pets, with the latter containing a field
linking it to its customer of ownership. I have a form with all of
the personal information of the customers, and within it is a list
box with all of the pets in it. In the current design, it takes that
information from a query, but since every customer is different, the
query needs to change each time. So, I just delete and recreate the
query each time the form is loaded or the record is changed. In the
off-chance that the query is deleted between form loads, it'll give an
error when it tries to debug, and I figure a workaround on the error
probably isn't the best way to do it.
I guess it's two questions, then. 1) Is this the best way to do it,
and 2) How do I figure out if a query already exists and needs to be
deleted?

#1) the built-in parent-child, form/subform relationships will probably
handle this for you

#2)

Public Function queryExists(qDefName as String) as Boolean

queryExists = IIf(DCount("[Name]","MSysObjects","[Name] = '" & qDefName &
"' AND [Type] = 5") = 1, True,False)

End Function
Jul 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
3
by: Irfan | last post by:
hi, All I have a table in Access and I am using a storedProcedure (Make-Table query) to overwrite this table. It gives an error that 'Table Already Exists', which is true. But i want it to...
8
by: bob | last post by:
I am writing some code to create new tables in a SQL database. However, I don't want to try to create a table if it already exists. How can I test beforehand to see if a particular named table...
1
by: delusion7 | last post by:
Trying to create a table and insert records from a webform and I keep getting this message: "Successfully created the registration table. Unable to execute the query. Error code...
10
by: ineedahelp | last post by:
Can anyone help me figure out why I continue to get a runtime error '3010' "TABLE qryMultiSelect ALREADY EXISTS'? Here is my code. thank you in advance for any help!!! Private Sub...
4
gundarap
by: gundarap | last post by:
Hello all, I'm working on minidom. My goal is to see whether an element already exists in the xml file before adding. I was using getElementsByTagName() to check weather the element already exists....
1
by: dwasler | last post by:
Try every thing I know to remove this alias I know there been other posting I read each one none seem to work. Thank You DLWasler dwasler@yahoo.com OS Window db2 V 8.2.X
2
by: jesus4gaveme03 | last post by:
I ceated a automatic split form from a table called "Master NSN List." I then added 2 buttons "cmdShowHide" which toggles between showing and hiding the form section giving more room for the...
0
by: Jason Hamilton | last post by:
Hey all, I have one of those strange issues where I swear I haven't run this code in two weeks and it was working perfectly when I ran it last but now I get an exception that I have not only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.