PDA

View Full Version : Solved: Assistance With a ComboBox



phendrena
01-23-2009, 08:09 AM
Hi everyone,

I've setup a ComboBox with :

MatchEntry :: 1 - frmMatchEntryComplete
MatchRequired :: True.

When the user now enters something that isn't on the list the default message box appears with "invalid property value".

How can I change this from the default to something else?

Thanks,

lucas
01-23-2009, 08:18 AM
There are at least 3 kinds of comboboxes that you could be talking about. How was it created?

phendrena
01-23-2009, 08:22 AM
There are at least 3 kinds of comboboxes that you could be talking about. How was it created?As far as i'm aware it's a normal combobox created using the combobox icon of the toolbox.

lucas
01-23-2009, 08:39 AM
I think you will have to set the MatchRequired = true back to false and just validate the selection:

Option Explicit
Private Sub CommandButton1_Click()
Select Case ComboBox1.ListIndex
Case 1
MsgBox "Selection 1 or Yadda1"
Case 2
MsgBox "Selection 2 or blah_2"
Case 3
MsgBox "Selection 3 or ho hum 3"
Case 4
MsgBox "Selection 4 or need a nap"
Case Else
MsgBox "BAD dog! Try again."
ComboBox1.ListIndex = 0
Exit Sub
End Select
' Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim whatever()
Dim var
whatever = Array("Please select an item", _
"yadda_1", "blah_2", _
"ho-hum_3", "Need a nap")
For var = 0 To UBound(whatever)
ComboBox1.AddItem whatever(var)
Next
ComboBox1.ListIndex = 0
End Sub

nst1107
01-23-2009, 08:59 AM
Steve, I love your choice of variables and strings.

lucas
01-23-2009, 09:06 AM
I'm a plagiarizer......I stole it from Gerry(fumei) in the Word forum. I loved it too. I also stole opensesame as a sub name for a module containing a userform show macro.......

we gotta have a little fun.

phendrena
01-23-2009, 10:02 AM
Thanks for you help.
That does work.