Please will someone help me with getting the correct results from my query using combo boxes in a form. I have set up a basic example with three query fields (ID, city, country). The combo boxes point to the table containg the same info (named: tbltrippy1). Query called: Qrytrippy2 and Form called: SearchForm2. Sorry about the names however just set this up to try and get to the bottom of my problem and thought it would be easier to post. I have set up a button to run the query from the form.
The SQL (written in the query page) is as follows:
SELECT tbltrippy1.ID, tbltrippy1.city, tbltrippy1.country
FROM tbltrippy1
WHERE (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo21])) OR (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo23]) AND (([Forms]![SearchForm2]![Combo21]) Is Null)) OR (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo25]) AND (([Forms]![SearchForm2]![Combo23]) Is Null)) OR ((([Forms]![SearchForm2]![Combo25]) Is Null));
sorry did this in a rush (Combo 21 is ID, Combo 23 is City and combo 25 is Country)
Unless all three combo boxes are completed all of the table values are shown. If all three are input the correct results are shown. I am trying to work out how to only get the fields matching the input criteria from the form to be shown e.g if data was:
ID city country
1 Berlin Germany
2 Paris France
3 London England
4 Canberra Australia
5 Washington DC America
6 Rome Italy
7 Oslo Norway
If 1, Berlin or Germany (or any 1 of the three) was entered it would return (1, Berlin, Germany) and the same for the others. I have tried adding a Like bit to the SQL however if I entered 1 and Paris it would return both the data on ID Line 1 and ID line 2 instead of returning nothing. I would like only 'all' matched fields to be shown (i.e. if ID 1 and Rome was entered nothing would be returned as both fields do not match the table data).
I hope that this makes sense, I am pretty new to this and it has been buggin me for days.
Any help would be appreciated thanks.
The SQL (written in the query page) is as follows:
SELECT tbltrippy1.ID, tbltrippy1.city, tbltrippy1.country
FROM tbltrippy1
WHERE (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo21])) OR (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo23]) AND (([Forms]![SearchForm2]![Combo21]) Is Null)) OR (((tbltrippy1.ID)=[Forms]![SearchForm2]![Combo25]) AND (([Forms]![SearchForm2]![Combo23]) Is Null)) OR ((([Forms]![SearchForm2]![Combo25]) Is Null));
sorry did this in a rush (Combo 21 is ID, Combo 23 is City and combo 25 is Country)
Unless all three combo boxes are completed all of the table values are shown. If all three are input the correct results are shown. I am trying to work out how to only get the fields matching the input criteria from the form to be shown e.g if data was:
ID city country
1 Berlin Germany
2 Paris France
3 London England
4 Canberra Australia
5 Washington DC America
6 Rome Italy
7 Oslo Norway
If 1, Berlin or Germany (or any 1 of the three) was entered it would return (1, Berlin, Germany) and the same for the others. I have tried adding a Like bit to the SQL however if I entered 1 and Paris it would return both the data on ID Line 1 and ID line 2 instead of returning nothing. I would like only 'all' matched fields to be shown (i.e. if ID 1 and Rome was entered nothing would be returned as both fields do not match the table data).
I hope that this makes sense, I am pretty new to this and it has been buggin me for days.
Any help would be appreciated thanks.