#  Other Applications & Softwares  > Access Tables & Databases >  >  One filter for 3 Queries in Union Query

## rlsublime

I currently have a union query with 3 queries linked to it. There is a Start and End date filter for all three queries. The start and end date filters pop up three times(One for each query). I am trying to only get it to pop up once but to apply the filter to all three queries in the Query Union.

----------


## ConneXionLost

Place two text boxes on a form and direct each set of query criterias to the text boxes (instead of the existing filters). Open the form, place the start and end dates in the text boxes, then run the union query.

----------


## rlsublime

Thanks. I am fairly new to access so I might need a little additional help. So far, I created a form named DateFilter with two text boxes and named one dtStart and the other dtEnd. I then a where statement in each of the three queries under the date that is to be filtered. Should I create some kind of button in the form to execute the UNION query? Also is my where statement correct?

"WHERE StartDate"="mm/dd/yyyy" & [Forms]![DateFilter].[dtStart] & "mm/dd/yyyy" And "EndDate"="mm/dd/yyyy" & [Forms]![DateFilter].[dtEnd] & "#"

----------


## ConneXionLost

A button is a good idea.

Just set the Startdate criteria in each query as [Forms]![DateFilter].[dtStart] and the EndDate criteria as [Forms]![DateFilter].[dtEnd]

----------


## rlsublime

Thanks for the clarification. I just entered this inthe criteria of the Date field:

Between [StartDate] And [EndDate] WHERE StartDate = #" & Forms!DateFilter.dtStart & "# AND EndDate = #" & Forms!DateFilter.dtEnd & "#"

But it said there is an invalid syntax. I am trying to figure out what the error is. Thanks for your help

----------


## ConneXionLost

Are you doing this in the source queries or the union query?

----------


## rlsublime

I am doing them in the source queries. Is this correct?

----------


## ConneXionLost

Yes. Are you using query design view, or SQL view?

----------


## rlsublime

I am using query design view. Is this correct

----------


## ConneXionLost

yes,

For the StartDate field, the criteria line should have:




```
Please Login or Register  to view this content.
```


and the EndDate field criteria line should be:




```
Please Login or Register  to view this content.
```


nothing more.

----------


## rlsublime

Thanks. I think my problem is that I only a DATE field. how could I break this down into start and end date and then point to the form? I think I might have missed a step. Thanks for the help.

----------


## ConneXionLost

If you only have one date field, then try:




```
Please Login or Register  to view this content.
```


in the criteria line.

----------


## rlsublime

that generates the query but it also displays a pop up for start and end 3 times(one for each query) I have the following in the date field criteria for all the queries

Between [Forms]![DateFilter].[dtStart] And [Forms]![DateFilter].[dtEnd]

Any ideas what might be causing the problem?

Thanks

----------


## ConneXionLost

Is the form open?

----------


## rlsublime

yes the form is open and i created a button to run the UNION Query. Any ideas what the problem might be?

Thanks

----------


## ConneXionLost

Switch to SQL view in one of your source queries, copy the SQL, and post it here.

----------


## rlsublime

This the UNION sql code. I have a command button on the form to generate this UNION query

select * from application_final 
UNION
select * from locked_final 
UNION select * from funded_final;

Thanks

----------


## ConneXionLost

And a source query?

----------


## rlsublime

how would i get to source query? Thanks

----------


## ConneXionLost

Open [application_final] in design view, then change the "view" button to SQL view.

----------


## rlsublime

i figured it out, the query parameters were set to START and END. I removed them and it generates perfectly. thanks for all your help,

----------

