Business Solutions: Access Combo Box: Various Properties

     by James D. Duncan, CPA

The combo box is very helpful in many ways.  Two procedures this month are how to automatically open the drop-down when we enter the combo box and how to leave a field showing for reference.   First we need a form to play deal with.  Using Access 2000, I clicked on forms, new, design view and start with a clean form.

Now, click on the combo box from the toolbox and drag and drop it on the form.  It will open up the combo box wizard.

Click next, choose a table you like and select 4 of the fields you want to experiment with.  I chose a table named Facility. Then set the column widths to fit.  And press next.

Select a label and press the Finish button.  Press the view button and we now have a combo box that looks something like this:

Cute, but only open when we click the selector button and only leaves the first column showing when we exit. 

First the auto open or dropdown on enter.  Right mouse click on the combo box and select properties. Click on the Event tab in the properties.   Select the On Enter properties, select the [Event Procedure] from the drop down and double click on the box with the 3 periods to the right of the drop down selector.  You will be taken into the Visual Basic part of Access to produce some code for the on enter event.  Enter Combo dropdown into the subroutine.  Notice that as soon as you type combo0.dr that IntelliSense starts to help you.

If you have been here before, this is old hat to you.  If not, pretty neat stuff.  Just press the enter key and the code will be completed for you.  Click the close button and we return to the Access design view window.  Now you have a subroutine to automatically dropdown the combo box when you enter it.  Press the form view and you will have an open combo box automatically.

 

Problem is when we exit the box we only have the first column left for reference.  Let’s say we wanted the address (3rd column) to stay for later reference.  Go back to the design view and select the text box from the tool box and drag it over to the form.  Move the label up and out of your road.  Or leave it, we are just practicing.  Now open the text box properties up and select the control source property.

 

Enter “=[Combo2].[column](3)” in the control source property.  We are telling the program that we want this box to have the contents of column 3 of the control named Combo2. 

 

Click on form view and see that the text box changes every time you pick a new item in the combo box. 

 

            This will let you leave more information on the screen or fill in other fields with any item in the combo box matrix.  You can do anything your imagination (and skill set) wants to do.

            I have shown just 2 minor uses of the combo box.  This control can be manipulated in many ways.  If you have a particular problem, sent it to me and I will try to give you an answer. 


James is a member of the OKCPCUG and an expert in Access and Excel. James can be reached at  BJ4DUNCAN@aol.com