Hi Bob...
Set mydb = CurrentDb()
On Error Resume Next
DoCmd.DeleteObject acQuery, "test"
strSQL = "SELECT * FROM tblScrubbedData "
strWhere = "WHERE "
If Not IsNull(Me.cbo_codeshare) Then
strWhere = "[CodeShare] In ("
For Each varItem In Me.cbo_codeshare.ItemsSelected
strWhere = strWhere & Me.cbo_codeshare.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
If Not IsNull(Me.lst_eqpa) Then
strWhere = "[EqpA] In ("
For Each varItem In Me.lst_eqpa.ItemsSelected
strWhere = strWhere & Me.lst_eqpa.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
If Not IsNull(Me.lst_orgs) Then
strWhere = strWhere & "[OrgS] In ("
For Each varItem In Me.lst_orgs.ItemsSelected
strWhere = strWhere & Me.lst_orgs.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
'########### I THINK THIS IS SUPPOSED TO BE "IF NOT flgSelectAll" ####################
'########### But I get NOTHING AT ALL if I put IF NOT here ####################
If flgSelectAll Then
strSQL = strSQL & strWhere
End If
Set qdef = mydb.CreateQueryDef("test", strSQL)
DoCmd.OpenQuery "test", acViewNormal
For Each varItem In Me.cbo_codeshare.ItemsSelected
Me.cbo_codeshare.Selected(varItem) = False
Next varItem
For Each varItem In Me.lst_orgs.ItemsSelected
Me.lst_orgs.Selected(varItem) = False
Next varItem
For Each varItem In Me.lst_eqpa.ItemsSelected
Me.lst_eqpa.Selected(varItem) = False
Next varItem
strWhere = ""
Set mydb = CurrentDb()
On Error Resume Next
DoCmd.DeleteObject acQuery, "test"
strSQL = "SELECT * FROM tblScrubbedData "
strWhere = "WHERE "
If Not IsNull(Me.cbo_codeshare) Then
strWhere = "[CodeShare] In ("
For Each varItem In Me.cbo_codeshare.ItemsSelected
strWhere = strWhere & Me.cbo_codeshare.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
If Not IsNull(Me.lst_eqpa) Then
strWhere = "[EqpA] In ("
For Each varItem In Me.lst_eqpa.ItemsSelected
strWhere = strWhere & Me.lst_eqpa.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
If Not IsNull(Me.lst_orgs) Then
strWhere = strWhere & "[OrgS] In ("
For Each varItem In Me.lst_orgs.ItemsSelected
strWhere = strWhere & Me.lst_orgs.ItemData(varItem) & ", "
Next
flgSelectAll = True
strWhere = Left(strWhere, Len(strWhere) - 2) & ") "
End If
'########### I THINK THIS IS SUPPOSED TO BE "IF NOT flgSelectAll" ####################
'########### But I get NOTHING AT ALL if I put IF NOT here ####################
If flgSelectAll Then
strSQL = strSQL & strWhere
End If
Set qdef = mydb.CreateQueryDef("test", strSQL)
DoCmd.OpenQuery "test", acViewNormal
For Each varItem In Me.cbo_codeshare.ItemsSelected
Me.cbo_codeshare.Selected(varItem) = False
Next varItem
For Each varItem In Me.lst_orgs.ItemsSelected
Me.lst_orgs.Selected(varItem) = False
Next varItem
For Each varItem In Me.lst_eqpa.ItemsSelected
Me.lst_eqpa.Selected(varItem) = False
Next varItem
strWhere = ""