I am trying to send the current record and the current subform record to Reports for printing.
Each record on the Form can have multiple records in the subform, however I only want to print the Main Form and the Current subform.
Form / subform are linked on EquipID and EquipIDfk and are working correctly.
Report / subreport are linked the same way and work correctly.
When I try to use the DoCmd.OpenReport... It is printing the data from the main form plus all subform records related to the main record.
I have tried the following Sub to filter the subreport without success.
Private Sub cmdPrintRecord_Click()
Dim strWhere As String
Dim strLook1 As String
Dim strLook2 As String
strLook1 = Me![EquipID]
strLook2 = Me![subfrmInspectionReport].Form![InspectionFindingspk]
strWhere = "[EquipID] = " & Me![EquipID] & " And " & "Reports![RptPrintRecord]![subrptInspectionReport].Report![InspectionFindingspk] = " _
& Me![subfrmInspectionReport].Form![InspectionFindingspk]
DoCmd.OpenReport "RptPrintRecord", acViewPreview, , strWhere
End Sub
Using Debug strLook1 and strLook2 both show they have the correct relevant record numbers and the value stored in strWhere is: [EquipID] = 745 And Reports![RptPrintRecord]![subrptInspectionReport].Report![InspectionFindingspk] = 8
This only prints an empty report. It seems that when I try to reference the subreport it goes pear shaped. Where am I going wrong?:banghead:
Each record on the Form can have multiple records in the subform, however I only want to print the Main Form and the Current subform.
Form / subform are linked on EquipID and EquipIDfk and are working correctly.
Report / subreport are linked the same way and work correctly.
When I try to use the DoCmd.OpenReport... It is printing the data from the main form plus all subform records related to the main record.
I have tried the following Sub to filter the subreport without success.
Private Sub cmdPrintRecord_Click()
Dim strWhere As String
Dim strLook1 As String
Dim strLook2 As String
strLook1 = Me![EquipID]
strLook2 = Me![subfrmInspectionReport].Form![InspectionFindingspk]
strWhere = "[EquipID] = " & Me![EquipID] & " And " & "Reports![RptPrintRecord]![subrptInspectionReport].Report![InspectionFindingspk] = " _
& Me![subfrmInspectionReport].Form![InspectionFindingspk]
DoCmd.OpenReport "RptPrintRecord", acViewPreview, , strWhere
End Sub
Using Debug strLook1 and strLook2 both show they have the correct relevant record numbers and the value stored in strWhere is: [EquipID] = 745 And Reports![RptPrintRecord]![subrptInspectionReport].Report![InspectionFindingspk] = 8
This only prints an empty report. It seems that when I try to reference the subreport it goes pear shaped. Where am I going wrong?:banghead: