@TheSmileyOne
Hey there,
Well the report pulls the data from the criteria string based on the table. I do not have any issues with that as the user can easily see his/her selection when they scroll down on the continuous form.
I modified code I found from Adapted from:
http://allenbrowne.com to suit my requirement.
I have a button that fires the filtering,here is the code associated:
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click
Dim strWhere As String 'The criteria string.
Dim lngLen As Long 'Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates in a JET query string.
If Not IsNull(Me.txtFilterLiaison) Then
strWhere = strWhere & "([Liaison_Contact_Information] = """ & Me.txtFilterLiaison & """) AND "
End If
If Not IsNull(Me.txtFilterSource) Then
strWhere = strWhere & "([Source] Like ""*" & Me.txtFilterSource & "*"") AND "
End If
If Not IsNull(Me.cboFilterProgram) Then
strWhere = strWhere & "([Program] Like ""*" & Me.cboFilterProgram & "*"") AND "
End If
If Not IsNull(Me.cboFilterStatus) Then
strWhere = strWhere & "([Status] Like ""*" & Me.cboFilterStatus & "*"") AND "
End If
If Not IsNull(Me.txtStartFilterDate) Then
strWhere = strWhere & "([Due_Date] >= " & Format(Me.txtStartFilterDate, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtEndFilterDate) Then 'Less than the next day.
strWhere = strWhere & "([Due_Date] < " & Format(Me.txtEndFilterDate + 1, conJetDate) & ") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
Exit_cmdFilter_Click:
Exit Sub
Err_cmdFilter_Click:
MsgBox Err.Description
Resume Exit_cmdFilter_Click
End Sub
Any advise would be greatly appreciated. Thx.