equivalant to notinlist for combobox

  • Thread starter Thread starter Stuart Holley
  • Start date Start date
S

Stuart Holley

Hi


I have a combobox which is filled form a sheet. The user then
types in an item 'csolbw07' if the item is not in the list a message
is displayed and asks the user if they want to add it to the list.

I have the code to put it in the list (sheet) but am having difficulty
in obtaining the 'csolbw07' from the combobox have tried numerous
combinations of listindex and list but have so far failed in all
attempts. Any ideas.


Many thanks
 
Stuart,

The List property contains only those items in the drop down list
part of the combobox. If you want to get the text from the
combobox that does not appear in the List, use the Value
property. E.g.,

MsgBox Me.ComboBox1.Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Chip

I have tried using value but it returns a "null" value.

here is my code may be you or someone could let me know where I am
going wrong. Please note there are some work arounds already in place
ie the inputbox but would like to get rid of it and just have one
responce from user.

Many thanks

Stuart


Private Sub ServerComboBox_AfterUpdate()
Dim Msg, Style, Title, Response, MyString, addservername
If ServerComboBox.MatchRequired = True Then
'MSForms handles this case automatically
Else
If ServerComboBox.MatchFound = True Then
'do nothing
Else

addservername = UserForm1.ServerComboBox.Value



Msg = "Server Not in list Do you want to add to list?" '
Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define
buttons.
Title = "Server Not In List" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
addservername = InputBox("Enter Server Name", "Add
To Server List") ' current work around
' call add server
Call addserversub(addservername) 'add to server
list if server is valid
Else ' User chose No.
MyString = "No" ' Perform some action.

Exit Sub
End If



End If

End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top