Hi Adam,
Put this code on your user form where the combo box is,
Private Sub userform_initialize()
Me.ComboBox1.List = Sheets("Clients").Range("__:__").Value
End Sub
I don't know the range of all the 'customer numbers' you have but just plug it in for example ("A6:A1000") thats the range of values that will show up on your combo box list!
So for your other problem, how to populate the text boxes when people search that customer number.
You basically have to
Private Sub cmbSearch_Click()
'For showing data on the form from the spreadsheet
n = LCase(Me.ComboBox1.Value)
y = Len(n)
x = 6
If n = "" Then
MsgBox ("Please choose Customer Number.")
GoTo J
End If
Do Until Left(n, y) = LCase(Left(Sheets("Clients").Cells(x, 2), y))
x = x + 1
If x = 1000 Then GoTo E
Loop
Load "INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'
Me.Textbox1.Value = Sheets("Clients").Cells(x, 2)
Me.TextBox2.Value = Sheets("Clients").Cells(x, 3)
Me.TextBox3.Value = Sheets("Clients").Cells(x, 4)
Me.TextBox4.Value = Sheets("Clients").Cells(x, 5)
Me.TextBox5.Value = Sheets("Clients").Cells(x, 6)
Me.TextBox7.Value = Sheets("Clients").Cells(x, 7)
Unload Me
"INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'" then add the .Show function
GoTo F
E:
Unload INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'
MsgBox ("This customer number does not exist in the database.")
F:
Unload Me
J:
End Sub
Bookmarks