No. You can not swap a value from one query to another, because a query does
not contain any values.
To change which records are displayed in a query, you have two choices - you
can change the data (which lives in the table, not in the query), so that it
meets the criteria of a different query, or you can change the SQL statement
that defines the query. Following on from my previous example, if QueryA
displays all records WHERE SomeField = 'X', while QueryB displays all
records WHERE SomeField = 'Y', and I want to change that around, I could do
it as follows ...
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("QueryA")
qdf.SQL = "SELECT * FROM SomeTable WHERE SomeField = 'Y'"
Set qdf = db.QueryDefs("QueryB")
qdf.SQL = "SELECT * FROM SomeTable WHERE SomeField = 'X'"
I might be able to offer a clearer explanation if I had more information -
are we really talking about displaying queries directly, or are we talking
about data displayed in form controls, such as combo boxes or list boxes,
based on those queries? This would, in my experience, by a much more common
requirement - filter one combo box or list box based on the item selected in
another, or allow a user to choose items from one list box and display those
choices in another. Is that what we're talking about here?
--
Brendan Reynolds
"Daniel Tan" <da*******@time.net.my> wrote in message
news:6a**************************@posting.google.c om...
Brendan, do you mean just swap the value of Somefield from one query
to another after i create a new query that comprise of the 2 sub
queries ?
Regards,
Daniel
"Brendan Reynolds" <br******@removethisindigo.ie> wrote in message
news:<BG*****************@news.indigo.ie>...
Records don't live in queries, they live in tables. Queries are just a
view of selected records. So the way to change which of the two queries
displays those records is to change whatever value it is that determines which
query displays the records.
For example, if you have two queries, one of which displays records
WHERE SomeField = 'X' and the other displays records WHERE SomeField = 'Y',
then you change the query that displays a particular record by changing the
value of SomeField in that record from 'X' to 'Y'.
--
Brendan Reynolds
"Daniel Tan" <da*******@time.net.my> wrote in message
news:6a**************************@posting.google.c om... Are there anyway to copy rows of records from one query to another
query and then hide the records in source query ? Pls advise. Thanks.
Regards,
Daniel