PDA

View Full Version : Text in Combo Box



junglej815
02-15-2008, 06:38 AM
Hi,

I have a word document with an active x combo box with 3 different possible choices that can be picked in the combo box.

I had this document returned to me from someone who typed in their own choice in the combo box.

Is there something that will make it so someone can't type their own stuff in the combo box and they can only choose 1 of the 3 choices?

thanks, and just let me know if more clarification is necessary.

Tinbendr
02-15-2008, 08:33 AM
Change the combo box to a listbox.

fumei
02-15-2008, 10:36 AM
That is one way. You could also do something like:Sub ComboBox1_LostFocus()
Dim myArray()
Dim var
Dim blnOK As Boolean
myArray = Array("First item", "Second Item", _
"Third item")
For var = 0 To UBound(myArray)
If ComboBox1.Text = myArray(var) Then
blnOK = True
End If
Next
If blnOK = False Then
MsgBox "Please select a listed item."
ComboBox1.ListIndex = 0
Exit Sub
End If
End SubThe array is the three items. The code runs through the current text of the combobox, and if it is NOT one of the three listed items, it displays a message, resets the combobox to the first item.


They can still type something into it, but it will never keep it.