Using Query results in another Query.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ive tried making a new query that uses the results of another query as the
selection criteria for the new query. The Criteria refer to a query called
[QryClinicButton1] with the field being [ClinicLocation] as below;

[QryClinicButton1]![ClinciLocation]

However this does not work, I get the message

"Enter parameter value" - QryClinicButton1!ClinciLocation.

When I "write" the results of the first query to a form, and then run the
second query criteria from the form 9which has to be open) it all works.
(Query criteria = [Forms]![FrmClinicButtonDisplay1]![ClinicLocation].
But this seems messy and longwinded, and with each of these queries
demanding an open form the user interface becomes cluttered with open forms
that the user does not actually need to see, Is there a better way?

Thanks Tim
 
Tim,

I assume QryClinicButton1 only ever returns 1 record? If that's the
case, then in your second query the criterion could be:

DFirst("[ClinciLocation]","QryClinicButton1")

Alternatively, it is highly likely that you could use a Domain Aggregate
functio applied directly on the underlying table, or a subquery in yor
second query, and drop QryClinicButton1 altogether. If you post back the
SQL expression of QryClinicButton1, I (or someone else) might cobe up
with a specific suggestion.

HTH,
Nikos
 
Nikos, thank you very much your DFirst statement works a treat! Thank you
again, Tim.


Nikos Yannacopoulos said:
Tim,

I assume QryClinicButton1 only ever returns 1 record? If that's the
case, then in your second query the criterion could be:

DFirst("[ClinciLocation]","QryClinicButton1")

Alternatively, it is highly likely that you could use a Domain Aggregate
functio applied directly on the underlying table, or a subquery in yor
second query, and drop QryClinicButton1 altogether. If you post back the
SQL expression of QryClinicButton1, I (or someone else) might cobe up
with a specific suggestion.

HTH,
Nikos
Ive tried making a new query that uses the results of another query as the
selection criteria for the new query. The Criteria refer to a query called
[QryClinicButton1] with the field being [ClinicLocation] as below;

[QryClinicButton1]![ClinciLocation]

However this does not work, I get the message

"Enter parameter value" - QryClinicButton1!ClinciLocation.

When I "write" the results of the first query to a form, and then run the
second query criteria from the form 9which has to be open) it all works.
(Query criteria = [Forms]![FrmClinicButtonDisplay1]![ClinicLocation].
But this seems messy and longwinded, and with each of these queries
demanding an open form the user interface becomes cluttered with open forms
that the user does not actually need to see, Is there a better way?

Thanks Tim
 
Back
Top