set an event property in access 2007 with VBA

I have a ton of controls on a form. I would like to dropdown the comboboxes without having to add an event property code for each control. is there some way to program something like
if ctl.controltype=acComboBox then

sub ctl_GotFocus()
ctl.dropdown
end sub
Brant KerseyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeCommented:
You could probably create a function:

Public Function DropdownOnFocus

    Dim ctrl as control

    set ctrl = screen.activecontrol
    if ctrl.ControlType = acComboBox Then
        ctrl.dropdown
    End If

End Function

Open in new window

Then, you could select all of those combo boxes and in the Got Focus event, you would enter:

= DropDownOnFocus()

However, this can be annoying if the user is simply tabbing (or hitting enter) through the controls.  You might want to use the Click event instead of the GotFocus event.
0
PatHartmanCommented:
This is something I think you can do with a class module.  This is what "with events" is for. But I can't give you details since I have not done it.  I would google  and see what happens.  Terms - class module, with events, raise.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.