D
Debbiedo
I have the follow code that builds a seach query in a search form. How
do I create a Print Preview button within this form to display the
results returned from this query? I can only get all the records to
display using the wizard.
Report name is CIT Report. Student_ID is the primary key used in both
the search query form and the CIT report.
Thanks for any and all help
Deb
-----------------------Code starts here------------
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
'Build Student ID criteria expresion
If Not IsNull(Me.txtFilterStudentID) Then
strWhere = strWhere & "([Student_ID] = """ &
Me.txtFilterStudentID & """) AND "
End If
'Build Last Name criteria expresion
If Not IsNull(Me.txtFilterLastName) Then
strWhere = strWhere & "([Last_Name] Like ""*" &
Me.txtFilterLastName & "*"") AND "
End If
'Build First Name criteria expresion
If Not IsNull(Me.txtFilterFirstName) Then
strWhere = strWhere & "([First_Name] Like ""*" &
Me.txtFilterFirstName & "*"") AND "
End If
' Build School Name criteria expression
If Len(Me.cboFilterSchool.Value & "") > 0 Then
strWhere = strWhere & "School_Name='" &
Me.cboFilterSchool.Value & "' And "
End If
' ... build "Approval" criteria expression
Select Case Me.frameApproval.Value
Case 1 ' Approved
strWhere = strWhere & "SPNDSBUS='X' And "
Case 2 ' Not Approved
strWhere = strWhere & "(Len(SPNDSBUS & '') = 0 ) And "
Case 3 ' Both
strWhere = strWhere & "([SPNDSBUS]OR(Len(SPNDSBUS & '') = 0))
And "
End Select
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing here"
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
do I create a Print Preview button within this form to display the
results returned from this query? I can only get all the records to
display using the wizard.
Report name is CIT Report. Student_ID is the primary key used in both
the search query form and the CIT report.
Thanks for any and all help
Deb
-----------------------Code starts here------------
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
'Build Student ID criteria expresion
If Not IsNull(Me.txtFilterStudentID) Then
strWhere = strWhere & "([Student_ID] = """ &
Me.txtFilterStudentID & """) AND "
End If
'Build Last Name criteria expresion
If Not IsNull(Me.txtFilterLastName) Then
strWhere = strWhere & "([Last_Name] Like ""*" &
Me.txtFilterLastName & "*"") AND "
End If
'Build First Name criteria expresion
If Not IsNull(Me.txtFilterFirstName) Then
strWhere = strWhere & "([First_Name] Like ""*" &
Me.txtFilterFirstName & "*"") AND "
End If
' Build School Name criteria expression
If Len(Me.cboFilterSchool.Value & "") > 0 Then
strWhere = strWhere & "School_Name='" &
Me.cboFilterSchool.Value & "' And "
End If
' ... build "Approval" criteria expression
Select Case Me.frameApproval.Value
Case 1 ' Approved
strWhere = strWhere & "SPNDSBUS='X' And "
Case 2 ' Not Approved
strWhere = strWhere & "(Len(SPNDSBUS & '') = 0 ) And "
Case 3 ' Both
strWhere = strWhere & "([SPNDSBUS]OR(Len(SPNDSBUS & '') = 0))
And "
End Select
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing here"
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub