query returns results from previous query

  • Thread starter Thread starter gthomson
  • Start date Start date
G

gthomson

Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a DoCmd.OpenQuery "<specificQuery>".
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]![Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
 
Narrowing down the problem. It occurs when I don't close
the previous query, and rerun a new query.

Question: Any way to use vba to close an open query


-----Original Message-----
Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a
DoCmd.OpenQuery said:
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]![Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
.
 
Narrowing down the problem. It occurs when I don't close
the previous query, and rerun a new query.

Question: Any way to use vba to close an open query
-----Original Message-----
Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a
DoCmd.OpenQuery said:
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]![Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
.

DoCmd.Close acQuery, "QueryName"
 
-----Original Message-----
Narrowing down the problem. It occurs when I don't close
the previous query, and rerun a new query.

Question: Any way to use vba to close an open query
-----Original Message-----
Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a
DoCmd.OpenQuery said:
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]! [Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
.

DoCmd.Close acQuery, "QueryName"
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
Thanks Fred:

I found that cmd, but I don't know in advance which query
will be open. Is there a query "collection" that vba can
use to identify all open queries?

Thanks again gt
 
-----Original Message-----
-----Original Message-----
Narrowing down the problem. It occurs when I don't close
the previous query, and rerun a new query.

Question: Any way to use vba to close an open query

-----Original Message-----
Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem
arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a
DoCmd.OpenQuery "<specificQuery>".
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]! [Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so
that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
.

DoCmd.Close acQuery, "QueryName"
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
Thanks Fred:

I found that cmd, but I don't know in advance which query
will be open. Is there a query "collection" that vba can
use to identify all open queries?

Thanks again gt
.

Problem solved. The original problem - the query displayed
results of previous query was due to fact that my app
wasn't closing the first query before issuing another. I
added vba code DoCmd.Close acQuery, "QueryName" for each
of the queries that users could run through the app into
the form activate procedure of my search form.
 
-----Original Message-----
-----Original Message-----
On Thu, 16 Sep 2004 13:56:07 -0700, gthomson wrote:

Narrowing down the problem. It occurs when I don't close
the previous query, and rerun a new query.

Question: Any way to use vba to close an open query

-----Original Message-----
Hi and thanks for your help:

Extreme newbie here. Let me narrate how this problem
arose.

I had three forms and three queries. Each form had a text
box for user input and a command button. The command
button was coded with a
DoCmd.OpenQuery "<specificQuery>".
Each of the three queries had the criteria field coded to
get its input from the appropriate textbox on the
appropriate form, for example, [Forms]![Welcome]! [Text6].
All was well in my world. Then I decided to combine the
forms into one main form w/ three textboxes and three
command buttons. I modified each query's criteria, so
that
it now got its input from the appropriate textbox on the
one form.

Problem. Now when I run the queries, they always return
the results of the previous query - even if I put
nonsensical input (or even nothing)into the textbox.

Anyone ever see anything like this?

Thanks again for your help.
.


DoCmd.Close acQuery, "QueryName"
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
Thanks Fred:

I found that cmd, but I don't know in advance which query
will be open. Is there a query "collection" that vba can
use to identify all open queries?

Thanks again gt
.

Problem solved. The original problem - the query displayed
results of previous query was due to fact that my app
wasn't closing the first query before issuing another. I
added vba code DoCmd.Close acQuery, "QueryName" for each
of the queries that users could run through the app into
the form activate procedure of my search form.

I just saw these last 2 posts of yours.
You can make it a bit easier.

In a module:

Public Sub CloseAllQueries()
Dim Db As Database
Dim qry As QueryDef
Set Db = CurrentDb
For Each qry In Db.QueryDefs
DoCmd.Close acQuery, qry.Name
Next qry
Set Db = Nothing
End Sub

Call it from any event:
CloseAllQueries
 
Back
Top