I have a multi feild search form that pulls the filtered results to the bottom of the form when the filter is applied. What can I add to this code to send it to a report (AdvSearchReport)? This is the code I use on the page: I have removed a lot of the search fields from this version to make it smaller.
Option Compare Database
Option Explicit
Private Sub 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.
'***********************************************************************
'Look at each search box, and build up the criteria string from the non-blank ones.
'***********************************************************************
If Not IsNull(Me.cboFilterHDRC) Then
strWhere = strWhere & "([Issues].[Ticket #] = " & Me.cboFilterHDRC & ") AND "
End If
If Not IsNull(Me.cboFilterIncident) Then
strWhere = strWhere & "([Incident Type] = " & Me.cboFilterIncident & ") AND "
End If
If Not IsNull(Me.txtFilterStatus) Then
strWhere = strWhere & "([Status] Like ""*" & Me.txtFilterStatus & "*"") AND "
End If
If Not IsNull(Me.cboFilterRespons) Then
strWhere = strWhere & "([Issues].[Responsible] = " & Me.cboFilterRespons & ") AND "
End If
'***********************************************************************
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "You must select at least one field to search by.", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Option Compare Database
Option Explicit
Private Sub 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.
'***********************************************************************
'Look at each search box, and build up the criteria string from the non-blank ones.
'***********************************************************************
If Not IsNull(Me.cboFilterHDRC) Then
strWhere = strWhere & "([Issues].[Ticket #] = " & Me.cboFilterHDRC & ") AND "
End If
If Not IsNull(Me.cboFilterIncident) Then
strWhere = strWhere & "([Incident Type] = " & Me.cboFilterIncident & ") AND "
End If
If Not IsNull(Me.txtFilterStatus) Then
strWhere = strWhere & "([Status] Like ""*" & Me.txtFilterStatus & "*"") AND "
End If
If Not IsNull(Me.cboFilterRespons) Then
strWhere = strWhere & "([Issues].[Responsible] = " & Me.cboFilterRespons & ") AND "
End If
'***********************************************************************
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "You must select at least one field to search by.", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub