Hi Richard,
Sorry I didn't understand you correctly, I actually didn't have any underlying code related to the combobox, that's what I was trying to figure out.
However, I have found a way to make the text box work to the manner I was looking for using AfterUpdate, I'll share the code:
Dim rg as range
Private Sub txtProd_AfterUpdate()
Application.ScreenUpdating = False
Prod = txtProd.Text
If Prod = "" Then GoTo Line2
On Error GoTo Line1
Sheets("Items").Select
With ThisWorkbook.Worksheets("Items")
Set rg = WorksheetFunction.Index(Range("A:A"), _
WorksheetFunction.Match(Prod, Range("A:A"), 0))
End With
Sheets("Collection").Select
Exit Sub
Line1:
Sheets("Collection").Select
MsgBox "That Product Doesn't Exist, Try Again", , "Invalid Product Name"
txtProd.Text = ""
txtProd.SetFocus
Line2:
Application.ScreenUpdating = True
Exit Sub
End Sub
As you said Richard, why give the user a free choice, which is what the combobox seems to let you do. This direction was just part of the path to a solution. I haven't dealt with comboboxes or listboxes before.
This code seems to work fine, although I am having trouble with the cursor going back to the txtProd text box after the error message and it being cleared. It seems the txtProd.SetFocus command doesn't work?
If you would like to help me with this that would be great, and also anything else you would like to comment on is welcome.
Norie, thanks for your reply also, I have edited this reply to recognise your support.
Thanks,
Yappa
Bookmarks