Parameters + Union queries + Order By = Unexpected Result

G

Guest

Somebody please help me with this perplexing problem.

I am trying to return the union of two queries, both of which use the
same parameters. When I don't try to sort the results, Access asks me
for the parameters one time each -- as I would expect. However, when I
add an Order By clause and execute the query, Access asks me for both
parameters twice. Why??? This is OK by me but my end users will
revolt.

Here is the form of the queries I'm using. The top level query is:

Query GetUnionOfTwoThings:

PARAMETERS
[Threshold] Currency,
[SomeParameter] Int;
Select *
From
GetStuffBelowThreshold
UNION
GetStuffAboveThrehold
ORDER BY
A,
B

.... and the subqueries are:

Query GetStuffAboveThreshold:

Select
ThisField as A,
ThatField as B
From
WhateverTable
Where
ThatField>[Threshold]


Query GetStuffBelowThreshold:

Select
Sum(ThisField) as A,
IIF(ThatField=999,999,ThatField/[SomeParameter]) as B
From
WhateverTable
Where
ThatField<=[Threshold]
Group By
ThisField,
IIF(ThatField=999,999,ThatField/[SomeParameter])

Thanks ... I'd really appreciate the help.

Regards,
-Gary Wolf
 
J

John Vinson

I am trying to return the union of two queries, both of which use the
same parameters. When I don't try to sort the results, Access asks me
for the parameters one time each -- as I would expect. However, when I
add an Order By clause and execute the query, Access asks me for both
parameters twice. Why??? This is OK by me but my end users will
revolt.

You might want to consider using a Form to solicit parameters, rather
than prompts; use criteria like

[Forms]![YourFormName]![YourControlName]

Put a command button on the form to launch the report or whatever else
you're doing with the union query.

Not sure why you're getting the two prompts though!

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SUM in a UNION query 2
Union query 5
Union Query 1
Union Query of Two Queries (Part 2) 2
union query of complex queries 1
Corsstab Queries 4
union query problem 16
Creating a parameter in a Union Query 2

Top