Question
August 21, 2007 at 02:12 PM
mikec

Using a combo box as criteria in Access

by mikec . Updated 18 years, 4 months ago

In a Microsoft Access 2003 database I have a table of information, it happens to be a list of rooms in a building and various information about each room. One column is called NAME and i have a combo box that a user can pull down and select from the various room names in the building (lots of duplicates, CLASSROOM for example). I have a button on the form which previews a report listing all the rooms that meet the criteria in the combo box

SELECT rooms.number, rooms.name
FROM rooms
WHERE (((rooms.name)=[forms]![roomquery].[combo1]))
ORDER BY rooms.number;

what i can’t figure out is how to get it to list ALL of the rooms when someone does not select something from the combo box. the combo box gets it’s row source from this query

SELECT rooms.name
FROM rooms
GROUP BY rooms.name
ORDER BY rooms.name;

so that it only gives the user the option of picking valid room names. i figured out how to do it with VB code attached to the button, but i end up with a nasty if-then-else tree since there will be about 20 fields on this form when it’s complete. any suggestions would be greatly appreciated!

This discussion is locked

All Comments