sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
kkleung89@gmail.com's Avatar

How do I figure out if a query already exists?


Question posted by: kkleung89@gmail.com (Guest) on July 13th, 2006 04:35 AM
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?

2 Answers Posted
Tom van Stiphout's Avatar
Tom van Stiphout July 13th, 2006 05:45 AM
Guest - n/a Posts
#2: Re: How do I figure out if a query already exists?

On 12 Jul 2006 20:40:49 -0700, Join Bytes! 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.

Quote:
Originally Posted by
>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?


DFS's Avatar
Guest - n/a Posts
#3: Re: How do I figure out if a query already exists?

Join Bytes! wrote:
Quote:
Originally Posted by
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


 
Not the answer you were looking for? Post your question . . .
196,991 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,991 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors