R
ruth
I want to use a different record source depending on whether my report was
filtered or not. If I request the report from the Student form, I want to use
qryBill for a single ID. If it's from the report form, I want to use
qryBilling, which selects based on criteria on the report form. I don't want
to have two versions of the report. My record source for the report is
qryBilling as a default.
On the student form I have the following code:
Private Sub PrintBill_Click()
On Error GoTo Err_PrintBill_Click
Dim stDocName As String
Dim PrintOption As Integer
Dim strWhere As String
If Me.PreviewBill Then PrintOption = 2
stDocName = "rptBilling"
strWhere = "ID=" & Me.ID
DoCmd.OpenReport stDocName, PrintOption, , strWhere
Exit_PrintBill_Click:
Exit Sub
Err_PrintBill_Click:
MsgBox Err.Description
Resume Exit_PrintBill_Click
End Sub
In the Open procedure of the rptBilling report I have:
Private Sub Report_Open(Cancel As Integer)
If Me.FilterOn Then Me.RecordSource = "qryBill"
End Sub
This doesn't seem to be working. qryBilling is always called and fails
because my report form is not open. When I debug, FilterOn is false and
Filter is "". How can I tell that I have passed a WHERE clause to the report?
I am using Access 2000.
filtered or not. If I request the report from the Student form, I want to use
qryBill for a single ID. If it's from the report form, I want to use
qryBilling, which selects based on criteria on the report form. I don't want
to have two versions of the report. My record source for the report is
qryBilling as a default.
On the student form I have the following code:
Private Sub PrintBill_Click()
On Error GoTo Err_PrintBill_Click
Dim stDocName As String
Dim PrintOption As Integer
Dim strWhere As String
If Me.PreviewBill Then PrintOption = 2
stDocName = "rptBilling"
strWhere = "ID=" & Me.ID
DoCmd.OpenReport stDocName, PrintOption, , strWhere
Exit_PrintBill_Click:
Exit Sub
Err_PrintBill_Click:
MsgBox Err.Description
Resume Exit_PrintBill_Click
End Sub
In the Open procedure of the rptBilling report I have:
Private Sub Report_Open(Cancel As Integer)
If Me.FilterOn Then Me.RecordSource = "qryBill"
End Sub
This doesn't seem to be working. qryBilling is always called and fails
because my report form is not open. When I debug, FilterOn is false and
Filter is "". How can I tell that I have passed a WHERE clause to the report?
I am using Access 2000.