A
Ac
Hi,
Is that possible that refer a report from a form?
I try to create a Search Form, there are some combo boxes on it to take the
input from a user; based on the multiple inputs, it will re-query the query
called qAll, then display the result on the report named ReportByStudents.
Below is the code, it does not work, could someone help me? Thanks!
Private Sub cmdReopenReportByStudents_Click()
Dim Where1 As String
Where1 = ""
If Not IsNull(cboStudentID) Then
Where1 = "Where CStr(StudentID) = """ + CStr(cboStudentID) + """"
End If
If Not IsNull(cboFirstName) Then
If Len(Where1) = 0 Then
Where1 = "Where FirstName = """ + cboFirstName + """"
Else
Where1 = Where1 + ("AND FirstName =""" + cboFirstName + """")
End If
End If
If Not IsNull(cboLastName) Then
If Len(Where1) = 0 Then
Where1 = "Where LastName = """ + (cboLastName) + """"
Else
Where1 = Where1 + ("AND LastName =""" + cboLastName + """")
End If
End If
If Not IsNull(cboCurEmployer) Then
If Len(Where1) = 0 Then
Where1 = "Where CurEmployer = """ + cboCurEmployer + """"
Else
Where1 = Where1 + ("AND CurEmployer = """ + cboCurEmployer + """")
End If
End If
If Not IsNull(cboClassID) Then
If Len(Where1) = 0 Then
Where1 = "Where CStr(ClassID) = """ + CStr(cboClassID) + """"
Else
Where1 = Where1 + ("AND Cstr(ClassID )= """ + CStr(cboClassID) + """")
End If
End If
If Not IsNull(cboClassName) Then
If Len(Where1) = 0 Then
Where1 = "Where ClassName = """ + cboClassName + """"
Else
Where1 = Where1 + ("AND ClassName = """ + cboClassName + """")
End If
End If
If Not IsNull(cboCompletionDate) Then
If Len(Where1) = 0 Then
Where1 = "Where CStr(CompletionDate) = """ +
CStr(cboCompletionDate) + """"
Else
Where1 = Where1 + ("AND CStr(CompletionDate) = """ +
CStr(cboCompletionDate) + """")
End If
End If
If Len(Where1) > 0 Then
Where1 = "Select * from qAll " + Where1
Report!ReportByStudents.Report.RecordSource = Where1
Report!ReportByStudents.Report.Requery
DoCmd.OpenReport "ReportByStudents", acViewPreview, , Where1
End If
End Sub
Is that possible that refer a report from a form?
I try to create a Search Form, there are some combo boxes on it to take the
input from a user; based on the multiple inputs, it will re-query the query
called qAll, then display the result on the report named ReportByStudents.
Below is the code, it does not work, could someone help me? Thanks!
Private Sub cmdReopenReportByStudents_Click()
Dim Where1 As String
Where1 = ""
If Not IsNull(cboStudentID) Then
Where1 = "Where CStr(StudentID) = """ + CStr(cboStudentID) + """"
End If
If Not IsNull(cboFirstName) Then
If Len(Where1) = 0 Then
Where1 = "Where FirstName = """ + cboFirstName + """"
Else
Where1 = Where1 + ("AND FirstName =""" + cboFirstName + """")
End If
End If
If Not IsNull(cboLastName) Then
If Len(Where1) = 0 Then
Where1 = "Where LastName = """ + (cboLastName) + """"
Else
Where1 = Where1 + ("AND LastName =""" + cboLastName + """")
End If
End If
If Not IsNull(cboCurEmployer) Then
If Len(Where1) = 0 Then
Where1 = "Where CurEmployer = """ + cboCurEmployer + """"
Else
Where1 = Where1 + ("AND CurEmployer = """ + cboCurEmployer + """")
End If
End If
If Not IsNull(cboClassID) Then
If Len(Where1) = 0 Then
Where1 = "Where CStr(ClassID) = """ + CStr(cboClassID) + """"
Else
Where1 = Where1 + ("AND Cstr(ClassID )= """ + CStr(cboClassID) + """")
End If
End If
If Not IsNull(cboClassName) Then
If Len(Where1) = 0 Then
Where1 = "Where ClassName = """ + cboClassName + """"
Else
Where1 = Where1 + ("AND ClassName = """ + cboClassName + """")
End If
End If
If Not IsNull(cboCompletionDate) Then
If Len(Where1) = 0 Then
Where1 = "Where CStr(CompletionDate) = """ +
CStr(cboCompletionDate) + """"
Else
Where1 = Where1 + ("AND CStr(CompletionDate) = """ +
CStr(cboCompletionDate) + """")
End If
End If
If Len(Where1) > 0 Then
Where1 = "Select * from qAll " + Where1
Report!ReportByStudents.Report.RecordSource = Where1
Report!ReportByStudents.Report.Requery
DoCmd.OpenReport "ReportByStudents", acViewPreview, , Where1
End If
End Sub