The four most common chemically active elements in the universe - hydrogen, oxygen, carbon, and nitrogen - are the four most common elements of life on Earth. We are not simply in the universe. The universe is in us.
I have a question on the part of using combo boxes to filter a list and display a report to print. I have a query which works great to filter out the data I need from a specific company I choose after selecting that company from a list in a combo box. The combo box gets it's values from a table inside the database. I also have a second combo box which also gets it's values from the same table inside the database the first combo box uses in order to get more specific data from out of that particular company and would like to display that data on the report. For example I have company "A", "B" and "C". Each company has a platoon "A", "B" and "C" inside it. I want to see a roster from company "B" from platoon "C" and display this data in a report from a single query, but I can't get the query to work right when I include the second combo box. When I have the query designed with just the first combo box filter for the companies inside the query does exactly what I want it to do, but when I add the second combo box filter for the platoons then the query doesn't work. I want the filter to give me data of the company and platoon I select in the combo box and if I leave the combo box blank for example I want it to give me all the companies (or platoons) in the appropriate combo box. So is I select company "B" in the first combo box and leave the second combo box blank I want to see all data from all platoons (meaning "A", "B" and "C") whom are under company "B" in a single report. If I select company "B" and platoon "C" then I only want to see the data from platoon "C" under company "B" in a single report. If I select platoon "C" in the second combo box and leave the first combo box blank I want to see data from platoon "C" from all platoons (meaning "A", "B" and "C"). If I leave both combo boxes blank I want to see all data from all companies and platoons.
The "LIKE" statement I used in the criteria of the query for the company field is:
Like [forms]![Administrative Reports]![Company]
I used the following expression in a field with the criteria stating --> Is Null <-- in the same query for the company:
Expr2: [forms]![Administrative Reports]![Company]
The "LIKE" statement I used in the criteria of the query for the company field is:
Like [forms]![Administrative Reports]![Platoon]
I used the following expression in a field with the criteria stating --> Is Null <-- in the same query for the company:
Expr2: [forms]![Administrative Reports]![Platoon]
If I could get the query to work right then everything else would fall into place and I could form the other reports I have generating other data on these companies and platoons to work right. I could use your expertise on this one. I figure it's something simple and I just am thinking on it too hard. When I have one search/filter combo box the quest works great. But when I added in the second search/filter combo box to get more exact data down to the platoon level I continually have issues and can't figure out how to get it to work. I reviewed your search and MS Access Expert level classes I purchased form you and still can't figure it out. Please get back with me on this ASAP. Any assistance you can provide me will be most appreciated. Thanks for your continued support and all that you do!
very respectfully,
EZELL MARTIN
Reply from Alex Hedley:
If you're using a LIKE you usually have a Wildcard (*) before and after the search term.
"SELECT * FROM x WHERE y LIKE *" & Term & "*"
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Search Seminar.