Share via

Restrict Combo Box

Anonymous
2011-07-10T04:21:43+00:00

Hi,

I am having a Combo Box in my form and I want the users to select or type only the data which is defined in the drop down list.  The users should be restricted by typing their own data in the Combo Box.

I have searched it in web and I got the below code and I made it in the Key Down procedure but the same is not working for me.

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

Please suggst.

Awaiting for your valuable reply.

Thanks in advance!

 ---

Sixthsense

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-07-10T09:50:35+00:00

It is not really possible to prevent the users from typing a value that does not occur in the list, but you can prevent it from being accepted: set the Limit to List property of the combo box to Yes. If the user types an invalid entry and presses Enter or Tab, Access will display an error message and refuse to accept the value.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful