Michelle86
IS-IT--Management
Hi,
I'm trying to have a form that allows the users to select search criteria from 3 drop down boxes. They can choose to select criteria from 1, 2 or all of the boxes.
However when I choose the criteria it only seems to work for the Division criteria on its own and none of the others!! Please help!!!!
Here's my code:
Hope the above made sense...
Any suggestions greatly received!
Thanks
Michelle
I'm trying to have a form that allows the users to select search criteria from 3 drop down boxes. They can choose to select criteria from 1, 2 or all of the boxes.
However when I choose the criteria it only seems to work for the Division criteria on its own and none of the others!! Please help!!!!
Here's my code:
Code:
Private Sub btnSearchForProspect_Click()
Dim StrCompany As String
Dim StrDivision As String
Dim StrStatus As String
Dim StrFilter As String
'Code to automatically open form
If SysCmd(acSysCmdGetObjectState, acForm, "frmEditProspect") <> acObjStateOpen Then
DoCmd.OpenForm "frmEditProspect", acViewNormal, StrFilter
End If
'Build Criteria string for Company
If IsNull(Me.cboCompanyDD.Value) Then
StrCompany = "Like '*'"
Else
StrCompany = "='" & Me.cboCompanyDD.Value & "'"
End If
'Build Criteria string for Division
If IsNull(Me.cboDivisionDD.Value) Then
StrDivision = "Like '*'"
Else
StrDivision = "='" & Me.cboDivisionDD.Value & "'"
End If
'Build Criteria string for Status
If IsNull(Me.cboStatusDD.Value) Then
StrStatus = "Like '*'"
Else
StrStatus = "='" & Me.cboStatusDD.Value & "'"
End If
'Combine criteria strings into WHERE clause for the filter
StrFilter = " [Company] " & StrCompany & " AND [Division] " & StrDivision & " AND [CurrentStatus] " & StrStatus
'Apply the filter and switch on
With Forms![frmEditProspect]
.Filter = StrFilter
.FilterOn = True
End With
End Sub
Hope the above made sense...
Any suggestions greatly received!
Thanks
Michelle