Disable Drop Down editing

Jerry8989

Registered User.
Local time
Today, 01:37
Joined
Mar 16, 2006
Messages
64
I would like to know what property stops the drop down from being edited at all. I have only in list set to yes but the user can still type in the drop down. I don't want them to be able to do that.
 
when they type into the dropdown it adds to the dropdown?
is the dropdown based on a query?
 
By typing in you scroll to the correct entry quicker - very useful if the entry you want srts with a letter a long way down the alphabet.

When you type in an entry that's not in the list you will get an error box displayed.
 
By typing in you scroll to the correct entry quicker - very useful if the entry you want srts with a letter a long way down the alphabet.

When you type in an entry that's not in the list you will get an error box displayed.

perhaps he wants a list box instead?
 
Sorry guys for the weak explanation.
I have about 6 things in the list. I want the drop down to acted like a web drop down. Then click the drop down and select and they aren't able to type anything in. I can't use a list box it has to be a drop down.

Thank You
Jerry
 
Code:
Private Sub YourDropDownName_KeyDown(KeyCode As Integer, Shift As Integer)
 KeyCode = 0
End Sub
 
It's often worth excluding keys that users might legitimately be pressing in the event... (e.g. the Tab key to navigate to the next control ;-)
e.g.
If KeyCode <> 9 Then
or a few such as Enter, Escape etc.

FWIW you can also cancel the event instead of reassigning the KeyCode.

Code:
    Select Case KeyCode
        Case 9, 13, 27 'Allow these key events to proceed
        Case Else
            DoCmd.CancelEvent
    End Select
 
missinglinq,
thank you that did the trick.

Does Keycode= 0 disable all the keys when the focus is on that control?

Jerry
 
Yes it does, and Leigh has a good point. If you want your users to only use the mouse to make selections my code is fine. Otherwise you need to allow certain keys as Leigh suggested. You might also allow the Up and Down Arrows:

Code:
Select Case KeyCode
  Case 9, 13, 27, vbKeyUp, vbKeyDown 'Allow these key events to proceed
   Case Else
   DoCmd.CancelEvent
End Select
 
Thanks for all the info guys I really appreciate it.

Jerry
 

Users who are viewing this thread

Back
Top Bottom