Prevent manual text input in combo boxes

G

Guest

I know if you set the "Limit To List" property to "Yes", it will prevent the
user from entering a value--when typed from keyboard--in the combo box. If
this happens, the user will recieve an error stating that you may not choose
a value that is not already in the list.

My question now is: Is there a way to eliminate the ability for the user to
type anything at all in the combo box but for the user to have no other
choice except to click the combo box to reveal a dropdown list of options?

Any input regarding this will be most helpful.
 
G

Guest

I think this is what the "combo" in "combo box" is all about - combination
drop-down and text entry. However, you could try this in the KeyUp event for
the control:

Combo1 = Null

This will reset the field to empty anytime a key is pressed (actualy, when
the key is released) while the control has the focus.
 
J

John Nurick

Perhaps better something like this in the KeyUp event procedure:

Select Case KeyCode
'These keys should work even in the combo box
Case vbKeyReturn, vbKeyTab, vbKeyEscape, _
vbKeyLeft, vbKeyRight, vbKeyF1
'so do nothing here

'The rest we want to suppress
Case Else
KeyCode = 0
End Select
 
G

Guest

Thanks you guys,

You've given more ideas on how I can further the use of combo boxes.
Eventhough, it couldn't do what i thought it can.

I was hoping the combo boxes or maybe some other control could emulate a
dropdown menu and let the user choose what available options on the list.

Anyways, it did the trick just fine. Thanks again.

Nils
 
T

TC

Nils said:
You've given more ideas on how I can further the use of combo boxes.
Eventhough, it couldn't do what i thought it can.


You want to stop the user typing into the box?

John's solution should work, if you did it in the KeyDown procedure.
Try that.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 

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