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!

Restricting Users From Typing Values Into ComboBox

Status
Not open for further replies.

palmese

Technical User
Dec 11, 2002
15
0
0
US
I have an Excel template that has a number of ComboBoxes in which a user will make selctions. I am having the problem of the user being able to override my ComboBox and type anything they want in the Box, thus circumventing the ComboBox choices. Example = ComboBox will have the choices "A", "B" or "C". The user has the ability to type "D" and print out the form with "D" in the ComboBox instead of being forced to choose "A-C".

I want to be able to "lock" the ComboBox so that the user will not be permitted to type anything over top the ComboBox. Any ideas for my problem would be greatly appreciated. Thanks.
 
Set the combo box .style property to 2-Dropdown List. Thanks and Good Luck!

zemp
 
Thanks Zemp! Worked like a charm.

I had one follow-up question. Now that I have set the combobox.style property to 2-Dropdown List, I am getting an error in my code related to the ClickButton I set up in order to &quot;Reset&quot; the form. The following is the code I used -- ComboBox1.Text = &quot;< Select Fund/Group >&quot;

This is the Error message I am getting: Run Time Error '380'. Could not set the Text property. Invalid property value.

Any ideas you have would be great! Thanks.
 
kmcclung - (could be wrong) but i dont think thats what palmese wants. to quote msdn

&quot;–1 (Default for ComboBox, DirListBox, and DriveListBox controls) Indicates no item is currently selected. For a ComboBox control, indicates the user has entered new text into the text box portion. For a DirListBox control, indicates theindex of the currentpath. For a DriveListBox control, indicates the index of the current drive when the control is created atrun time.&quot;

palmese - if your removing all the entries then adding the line &quot;< Select Fund/Group >&quot;
you could try

combo1.clear
combo1.additem &quot;< Select Fund/Group >&quot;

or if you just want to select the first entry in the combobox (which i assume is &quot;< Select Fund/Group >&quot;)
then set

combo1.listindex=0

hope this is of some use.
 
reset the style to wot u previously had, and then type this in to the Combo's Keypress Event

KeyAscii = 0

Now u can set the text, addnew elements, but u cant type.. is this wot u want? All the Best
Praveen Menon
pcmin@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top