Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit keys in combo box

Status
Not open for further replies.

r111ufus

Instructor
Jun 7, 2001
2
0
0
US
Is there a way to limit user keys to patterns listed in item for combobox? If my items are - aaa,bbb,ccc -- then only the a key can be used if an a is depressed first, all other keys would be disregarded. I know how to do it in vb but not vba.
Thanks
 
Use the combo box's KeyPress event. The .Text property gives what's currently visible in the text box part (as opposed to the .Value property, which gives the last completely entered value). So just check .Text; if it's empty, any key is ok. If it's not empty, you test the keystroke for validity, and if it's not valid, you beep and set the KeyAscii argument to 0 to cancel the keystroke. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top