Auto open combo box options?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Our Access database is used for entering survey questionaire data. Many
fields have combo boxes with several options.

I would like the combo box look-up to open automatically when a person
clicks or tabs over to a field box instead of having to press f4 as a
shortcut.

Any help would be appriciated!
 
Thank you, Yanick! Just for anyone else who may want to do this, I created
the following code (S_Q1 is a field, or question 1):

Private Sub S_Q1_GotFocus()
Me.S_Q1.Dropdown
End Sub

Is there a way, do you think, to have one code for all combo boxes of a
form? I tried to fiddle with some coding, but unable to make it work.
 
Try something like this.

Named all your combo box with the same name + a number : ex.:
Combobox1,Combobox2,Combobox3 ...

Then with a for...next, access the drop down propertie.

Dim i as integer

For i = 1 to 3
Me("Combobox" & i).dropdown
next i

Yanick
 
Sorry Yanick, I don't think that will work. (At least it doesn't in A2K, on
my machine). For one thing, you need to SetFocus to a control before you can
make it drop; for another, as soon as you SetFocus to another control, the
previous one rolls up again.

To nshippers, as far as I've been able to determine, what you want isn't
possible. I wish it was, I use the drop-on-entry functionality a lot, it
just makes sense to me to have a combobox drop open automatically in many
situations, instead of waiting for the user to do it manually. I wish there
was a DropOnEntry property for comboboxes that I could check yes or no,
instead of always having to code it. But there doesn't seem to be any other
way than by writing event code for each box. You could write a routine that
contained the code Me.ActiveControl.DropDown, but you would still have to
call that routine from each combobox's event code, which would actually be
more work than simply putting the DropDown command directly in the event
routine.

And there are some issues with the ActiveControl method. I'm not sure
exactly what the problem is, you could probably scan the archives to see
what people have to say about it. I believe the major issue is that, in
complicated routines, the active control may suddenly become something other
than what you thought. I only use it in things like the OnEntry or GotFocus
event routines, where I know for certain what the active control is, so I've
never had any problems with it. You could code your drop command as
ActiveControl.DropDown, then simply paste that line into the GotFocus or
OnEntry event routine of every combobox that you want to act this way. It
would at least save you having to type each combobox's name. I do that a lot
and it's always worked for me.

Pete
 
Actually, I just thought of a better way to do this while reading another
post in this NG. You can write a common routine and call it directly from
each event property that interests you.

Create something like:

Public Function DropMeBaby()
ActiveControl.DropDown
End Function

Note that it MUST be a function, not a sub! Then put

=DropMeBaby()

in the event property box for any control/event where you want this to
happen. Much simpler than my first suggestion (and whyinhell haven't I been
doing this all along? Oh well.)

Pete
 
Back
Top