I have a combo box on a form that when I start typing it gives me a dropdown menu of all part names that start with what I type, then I can select which one I want and it goes to that record. This works fine with the code below. I want to add in another criteria.
I also have another combo box called cboMachine on the form, that's controlsource is Machine which is in the same table as part Name. I reckon I have to add to this line strRowSource = "SELECT ID, [Part Name] FROM [Part Details]"
What I need to put and where I don't know. If anyone could help that would be much appreciated.
Private Sub cbomachineSelect_Change()
Dim strRowSource As String
strRowSource = "SELECT ID, [Part Name] FROM [Part Details]"
If Len(Me!cbomachineSelect.Text) = 4 Then
strRowSource = strRowSource & " WHERE [Part Name] Like '"
strRowSource = strRowSource & Me!cbomachineSelect.Text
strRowSource = strRowSource & "*'"
Me!cbomachineSelect.RowSource = strRowSource
Me!cbomachineSelect.Dropdown
End If
End Sub