|
Question : Problem with subreport printing?
|
|
Using Access97
I have a report called Roast Colors Report that has a subreport. I use the following code to print the report:
Private Sub Command45_Click() On Error GoTo Err_Command45_Click Dim strWhereCategory As String If Me![optBeginDt] = "" Or Me![optEndDt] = "" Then Beep MsgBox "Please enter a valid start date", vbInformation, "Date Error" Me![optBeginDt].SetFocus Else
strWhereCategory = "date between Forms![Daily Reports]!optBeginDt and Forms![Daily Reports]!optEndDt" Select Case Me![ReportToPrint] Case 2 DoCmd.OpenReport "Roast Colors Report", acViewPreview, , strWhereCategory DoCmd.PrintOut acPages, , , , nbrcopies DoCmd.Close End Select DoCmd.Close acForm, "Daily Reports" End If
Exit_Command45_Click: Exit Sub
Err_Command45_Click: MsgBox Err.Description Resume Exit_Command45_Click End Sub
As you can see the report is printed by a user entered date range. When I print this report the date range works fine for the main report but the subreport will print the whole table of information. How do I get this subreport to obey the date range limitations?
Thanks,
Bill Neuman
|
|
Answer : Problem with subreport printing?
|
|
Make RecordSource of SubReport:
Select ... From ... Where ... AND (date between Forms![Daily Reports]!optBeginDt and Forms![Daily Reports]!optEndDt)
|
|
|
|