Union Query Date Parameter Issue

F

FA

Hi Freinds,
I have a Union Query that have three select statements and each select
statements as follows.

Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field1 ) Between Date()-7 And Date()
Union
Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "No Test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field2 ) Between Date()-7 And Date()

Instead of (TableA.Field1 ) Between Date()-7 And Date() and
(TableA.Field2) Between Date()-7 And Date(), i want user to enter one
date range meaning begin date and end date and it should applies on
both select statement. Since Select staement number1 date is Field1 and
Select staement number2 date is Field2, i dont know how should i take
only one input from the user and applies on both select statement.

If someone knows anything about it please please help me

Thanks

Moe
 
C

Cinzia

FA said:
Hi Freinds,
I have a Union Query that have three select statements and each select
statements as follows.

Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field1 ) Between Date()-7 And Date()
Union
Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "No Test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field2 ) Between Date()-7 And Date()

Instead of (TableA.Field1 ) Between Date()-7 And Date() and
(TableA.Field2) Between Date()-7 And Date(), i want user to enter one
date range meaning begin date and end date and it should applies on
both select statement. Since Select staement number1 date is Field1 and
Select staement number2 date is Field2, i dont know how should i take
only one input from the user and applies on both select statement.

If someone knows anything about it please please help me

Thanks

Moe

Hi Moe,
try this:

Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field1 ) Between [FromDate?] And [ToDate?]
Union
Select TableA.Field1,TableA.Field2,TableB.Field3 From TableA, TableB
Where TableB.Field3 = "No Test"
Group By TableA.Field1,TableA.Field2,TableB.Field3
Having (TableA.Field2 ) Between [FromDate?] And [ToDate?]
 

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

Top