Multi choice list box and two ALL selection

N

nybaseball22

Hello. I have a pop-up form that has 2 list boxes. I want to do 3
things.

On the list boxes, I want to make them multi-choice list boxes.
Second, I want to make a selection of "all" for both list boxes. And
last, I would like to have the text boxes default to the all
selection, if possible, until another selection is made.

The list boxes are:

CarList
EventList

They are populated by tables - Automobiles - Car Table and Automobiles
- Action Taken Table, respectively.

Finally, they run through query called AutomobileSearch.

Thanks for the help.
 
D

Dale Fye

To make your list multi-select, click the list in the forms design view. In
the properties dialog, select the Other tab and change Multi Select to Simple
or Extended.

To add an All option to your list, you will need to create a union query
that adds the "All" option to the list and ensures that it will be at the
top. I usually keep a table (tbl_Numbers) which contains a single field
NumValue, and 9 records (the numbers 0 through 9) in my database for this
purpose.

You should be able to take your current query, view it in design mode and
then change over to the SQL mode to get this to work. Obviously, you will
need to use your own field names.

SELECT NumValue as ID, "All Cars" as CarName
FROM tbl_Numbers
WHERE NumValue = 0
UNION ALL
SELECT CarID as ID, CarName
FROM [Automobiles - Car]
ORDER BY CarName

In the forms Open event, you just need to set the value of the list to zero
in order for this to work, assuming that the bound column of your combo box
is column 1.

Private Sub Form_Open

me.lst_Cars = 0
me.lst_Action = 0

End Sub

BTW, I recommend against putting spaces in table or field names. Whenever
you do so, it makes it mandatory that you wrap the table of field name in
brackets [], and increases your workload. I recommend one of the following.

1. Camel case: This involves capitalizing the first letter of each word in
a table or field name (AutomobilesCar, AutomobilesAction).
2. Use the underscore to separate the words (Automobiles_Car). This is the
way I usually do it.

HTH
Dale
 

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