N
Nick W
Hi All,
I have a continous form where the users can filter the records using
text and combo boxes - see code below:
Private Sub CmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.Combo0) Then
strWhere = strWhere & "([Directorate] = """ & Me.Combo0 & """)
AND "
End If
If Not IsNull(Me.Combo112) Then
strWhere = strWhere & "([SuccessfulChosen] = """ & Me.Combo112
& """) AND "
End If
If Not IsNull(Me.Combo12) Then
strWhere = strWhere & "([FTE] = """ & Me.Combo12 & """) AND "
End If
If Not IsNull(Me.Combo14) Then
strWhere = strWhere & "([EmploymentStatus] = """ & Me.Combo14
& """) AND "
End If
If Not IsNull(Me.Combo16) Then
strWhere = strWhere & "([JobLocation] = """ & Me.Combo16 &
""") AND "
End If
If Not IsNull(Me.Combo18) Then
strWhere = strWhere & "([ManagerDetails] = """ & Me.Combo18 &
""") AND "
End If
If Not IsNull(Me.Combo24) Then
strWhere = strWhere & "([Section] = """ & Me.Combo24 & """)
AND "
End If
If Not IsNull(Me.Combo26) Then
strWhere = strWhere & "([RecruitmentContactID] = " &
Me.Combo26 & ") AND "
End If
If Not IsNull(Me.Combo92) Then
strWhere = strWhere & "([JobStatusID] = " & Me.Combo92 & ")
AND "
End If
If Not IsNull(Me.Combo32) Then
strWhere = strWhere & "([Internal/ExternalID] = " & Me.Combo32
& ") AND "
End If
If Not IsNull(Me.Combo30) Then
strWhere = strWhere & "([ReasonForJobID] = " & Me.Combo30 & ")
AND "
End If
If Not IsNull(Me.Combo22) Then
strWhere = strWhere & "([TblJobSkillset].[SkillsetCategoryID]
= " & Me.Combo22 & ") AND "
End If
If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([RAFApprovalDate] >= " &
Format(Me.Text2, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text4) Then
strWhere = strWhere & "([RAFApprovalDate] < " &
Format(Me.Text4 + 1, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text128) Then
strWhere = strWhere & "([QryAllClosingDates].[ClosingDate] >=
" & Format(Me.Text128, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text130) Then
strWhere = strWhere & "([QryAllClosingDates].[ClosingDate] < "
& Format(Me.Text130 + 1, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text6) Then
strWhere = strWhere & "([Expiry Date] >= " & Format(Me.Text6,
conJetDate) & ") AND "
End If
If Not IsNull(Me.Text8) Then
strWhere = strWhere & "([Expiry Date] < " & Format(Me.Text8 +
1, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click()
Dim ctl As Control
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
'Remove the form's filter.
'Me.Filter = "(False)"
'Me.FilterOn = True
End Sub
However the users would like to be able to select more than one item
from some of the combo boxes, I assume to be able to do this I would
need to replace those combo boxes with list boxes however I'm unsure
whether this is possible, if so how do I go about doing it, and if not
can anyone offer an alternative solution?
Thanks in advance
Nick
I have a continous form where the users can filter the records using
text and combo boxes - see code below:
Private Sub CmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.Combo0) Then
strWhere = strWhere & "([Directorate] = """ & Me.Combo0 & """)
AND "
End If
If Not IsNull(Me.Combo112) Then
strWhere = strWhere & "([SuccessfulChosen] = """ & Me.Combo112
& """) AND "
End If
If Not IsNull(Me.Combo12) Then
strWhere = strWhere & "([FTE] = """ & Me.Combo12 & """) AND "
End If
If Not IsNull(Me.Combo14) Then
strWhere = strWhere & "([EmploymentStatus] = """ & Me.Combo14
& """) AND "
End If
If Not IsNull(Me.Combo16) Then
strWhere = strWhere & "([JobLocation] = """ & Me.Combo16 &
""") AND "
End If
If Not IsNull(Me.Combo18) Then
strWhere = strWhere & "([ManagerDetails] = """ & Me.Combo18 &
""") AND "
End If
If Not IsNull(Me.Combo24) Then
strWhere = strWhere & "([Section] = """ & Me.Combo24 & """)
AND "
End If
If Not IsNull(Me.Combo26) Then
strWhere = strWhere & "([RecruitmentContactID] = " &
Me.Combo26 & ") AND "
End If
If Not IsNull(Me.Combo92) Then
strWhere = strWhere & "([JobStatusID] = " & Me.Combo92 & ")
AND "
End If
If Not IsNull(Me.Combo32) Then
strWhere = strWhere & "([Internal/ExternalID] = " & Me.Combo32
& ") AND "
End If
If Not IsNull(Me.Combo30) Then
strWhere = strWhere & "([ReasonForJobID] = " & Me.Combo30 & ")
AND "
End If
If Not IsNull(Me.Combo22) Then
strWhere = strWhere & "([TblJobSkillset].[SkillsetCategoryID]
= " & Me.Combo22 & ") AND "
End If
If Not IsNull(Me.Text2) Then
strWhere = strWhere & "([RAFApprovalDate] >= " &
Format(Me.Text2, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text4) Then
strWhere = strWhere & "([RAFApprovalDate] < " &
Format(Me.Text4 + 1, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text128) Then
strWhere = strWhere & "([QryAllClosingDates].[ClosingDate] >=
" & Format(Me.Text128, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text130) Then
strWhere = strWhere & "([QryAllClosingDates].[ClosingDate] < "
& Format(Me.Text130 + 1, conJetDate) & ") AND "
End If
If Not IsNull(Me.Text6) Then
strWhere = strWhere & "([Expiry Date] >= " & Format(Me.Text6,
conJetDate) & ") AND "
End If
If Not IsNull(Me.Text8) Then
strWhere = strWhere & "([Expiry Date] < " & Format(Me.Text8 +
1, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click()
Dim ctl As Control
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
'Remove the form's filter.
'Me.Filter = "(False)"
'Me.FilterOn = True
End Sub
However the users would like to be able to select more than one item
from some of the combo boxes, I assume to be able to do this I would
need to replace those combo boxes with list boxes however I'm unsure
whether this is possible, if so how do I go about doing it, and if not
can anyone offer an alternative solution?
Thanks in advance
Nick