Make Access combo boxes drop down automatically

Tue, Jul 21, 2009

Data Management

Make Access combo boxes drop down automatically

dropdownBy default, in order to see the items in a combo box, you need to click on the little arrow in the drop down box. This can get tedious, especially if there are a lot of combo boxes on your form. It’s also not efficient for high speed data entry, like using TAB to move through controls and the number pad or arrow keys to select answers. With just a few lines of code, you can make your combo boxes drop down automatically when the cursor enters them. I’ll show you two ways to accomplish this.

After the video I list the steps for both methods. You can just read those but if you get lost, the video should clarify everything.

http://www.researchtutorials.com/videos/dm/dropdown6.flv

Method 1: Apply the drop down setting to combo boxes, one by one

This method is useful if you’re dealing only with a few combo boxes.

  1. Open the form in Design View
  2. Double click on the combo box to open its properties box
  3. Click the Enter tab
  4. In the On Enter line, click the dropdown arrow and select [EventProcedure]
  5. Click the marching ants (…). This open the Visual Basic window.
  6. In between the two lines of code already provided (Private Sub … End Sub), type the following:
Me.q1.Dropdown

So the final code should look like this:

Private Sub q1_Enter()
   Me.q1.Dropdown
End Sub

(This example assumes q1 is the name of your combo box.)

  1. Close the Visual Basic window (big red X, top right corner)
  2. Close the still open properties box
  3. Open your form in Form View and test it out.

Method 2: Apply the setting to multiple combo boxes, all at once

This method is useful if you want to apply the setting to many combo boxes at once. Also, because the code is in what’s called a “global module,” you can use it with combo boxes on many different forms. (“Global” means the code can be referred to from any form in your database.) This is more efficient and results in less code filling up your database.

  1. In the Access database window, click on Modules. (If the database window isn’t showing, it’s probably hiding behind an open form. Close or minimize your form, or hit F11 to pull it up.)
  2. Click New. This opens the Visual Basic window.
  3. Type the following:
Function DropdownCombo()
On Error Resume Next
   Screen.ActiveControl.Dropdown
End Function
  1. Click Save, give the module a name (e.g., modDropdown), and click OK
  2. Close the Visual Basic window (big red X, top right corner)
  3. In the Access database window, click on Forms
  4. Select your form
  5. Click Design
  6. Click the combo box or combo boxes to which you’d like to apply the drop down feature. (To select multiple combo boxes, hold down SHIFT while clicking them. This allows you to create a “Multiple Selection.”)
  7. Once you’ve selected them, hover your mouse over any one of them until you see the flat hand
  8. Right click, choose Properties
  9. Click on the Event tab
  10. On the On Enter line, type this: =DropdownCombo()
  11. Close the Properties box
  12. Open the form in Form View to test it out.

Downloads

http://www.researchtutorials.com/wp-content/plugins/downloads-manager/img/icons/default.gif Download: Dropdown Combo Box Example (Access 2003) (792KB)
Added: 28/07/2009
Tutorial: Make Access combo boxes drop down automatically http://www.researchtutorials.com/data-management/make-access-combo-boxes-drop-down-automatically/

  • Hotmail
  • Yahoo Mail
  • Evernote
  • Delicious
  • Digg
  • Share/Bookmark
,

3 Responses to “Make Access combo boxes drop down automatically”

  1. Aaron Says:

    I saw your post on TechSmith.com forum and decided to look around your site. The Access tutorials are really helpful. Nice production in Camtasia !

    Reply

  2. Philip Says:

    Thank you, i found this to be a very well written tutorial. :)

    Reply

  3. Img Says:

    Thank you, i found this to be a very well written tutorial.
    +1

    Reply


Leave a Reply