Ok. So what you are saying is each list box, instead of a join to my main table, I don't require that. I can just do something like:
select distinct st_cd from state; select distinct lob from lob; select distinct measure from measures; and so on and place that in my rowsource. Nothing at all goes into the recordsource anywhere. Not even on the main form. Instead use filter and filter on. I read through the link and trying to determine what to do with filter and filter on. I did alter my code based on his example for the command9 button titled click for results and had to change I think to 1 instead of 5 because st_cd is only 2. I think I am still doing something wrong because when clicking on click for results it comes back no criteria. I have my filter on load changed to yes and trying to determine what goes into the filter section. Maybe that is why nothing is found. Or maybe I have to have something different in the [] items. Maybe I have to put a query in there?
Code:
Option Compare Database
Option Explicit
Private Sub Command8_Click()
Dim strWhere As String
Dim lngLen As Long
'List Boxes.
If Not IsNull(Me.List1) Then
strWhere = strWhere & "([lob] = """ & Me.List1 & """) AND "
End If
If Not IsNull(Me.List2) Then
strWhere = strWhere & "([yr] = """ & Me.List1 & """) AND "
End If
If Not IsNull(Me.List3) Then
strWhere = strWhere & "([mth] = """ & Me.List3 & """) AND "
End If
If Not IsNull(Me.List4) Then
strWhere = strWhere & "([st_cd] = """ & Me.List4 & """) AND "
End If
If Not IsNull(Me.List5) Then
strWhere = strWhere & "([bus_unit] = """ & Me.List5 & """) AND "
End If
If Not IsNull(Me.List6) Then
strWhere = strWhere & "([prod_nm] = """ & Me.List6 & """) AND "
End If
If Not IsNull(Me.list7) Then
strWhere = strWhere & "([condition_category] = """ & Me.list7 & """) AND "
End If
If Not IsNull(Me.list8) Then
strWhere = strWhere & "([measure] = """ & Me.list8 & """) AND "
End If
If Not IsNull(Me.list9) Then
strWhere = strWhere & "([sub_measure] = """ & Me.list9 & """) AND "
End If
If Not IsNull(Me.List10) Then
strWhere = strWhere & "([comm_lvl] = """ & Me.List10 & """) AND "
End If
If Not IsNull(Me.List11) Then
strWhere = strWhere & "([comm_type] = """ & Me.List11 & """) AND "
End If
lngLen = Len(strWhere) - 1
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub Command9_Click()
Dim ctl As Control
For Each ctl In Me.Section(acDetail).Controls
Select Case ctl.ControlType
Case acListBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
Me.FilterOn = False
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "You cannot add new data to this search form.", vbInformation, "Permission denied."
End Sub
Private Sub Form_Open(Cancel As Integer)
End Sub