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

How do I figure out if a query already exists?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.