Oh it just dawned on me!
The problem is without selecting the values in the MAchine listbox all values in the other listboxes are getting displayed after clicking their respective select button. How do I eliminate this?
That's because in your code if the loop doesn't find a selected list item you essentially no longer have a WHERE clause in your sql statement.
Insert this line between Next intMachineID and strSQLstr = "SELECT tblMachineSystem.[Machine System ID]...
Code:
If strWhrMachineID = "" Then Exit Sub
Should look like
Code:
For intMachineID = 0 To Form_frmFILTER.listMachine.ListCount - 1
If Form_frmFILTER.listMachine.Selected(intMachineID) Then
If strWhrMachineID <> "" Then
strWhrMachineID = strWhrMachineID & " or " & "tblMachineSystem.[MAchine ID] = " & Form_frmFILTER.listMachine.Column(0, intMachineID)
Else
strWhrMachineID = "Where " & "tblMachineSystem.[MAchine ID] = " & Form_frmFILTER.listMachine.Column(0, intMachineID)
End If
End If
Next intMachineID
If strWhrMachineID = "" Then Exit Sub
strSQLstr = "SELECT tblMachineSystem.[Machine System ID], tblMachineSystem.[Machine System], tblMachineSystem.[MAchine ID] " & _
"FROM tblMachineSystem " & strWhrMachineID
Set rsData = CurrentDb.OpenRecordset(strSQLstr)
If there are no selections in the first listbox this line will quit the sub leaving listbox 2 empty.