Syncing current subform to subreport (1 Viewer)

KaomboTel

New member
Local time
Today, 08:21
Joined
Aug 12, 2014
Messages
9
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:
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
If the subform is linked to the main form via an ID you only need one criteria sent to report.
 

KaomboTel

New member
Local time
Today, 08:21
Joined
Aug 12, 2014
Messages
9
If I only send one critera the report will print all the records associated with the Main form. I need to limit the output to the current subform record.
 

vbaInet

AWF VIP
Local time
Today, 16:21
Joined
Jan 22, 2010
Messages
26,374
I think I understand what you mean. You want to print a report of the current record of the main form that's tied to the subform and also limit the subreport to the current record of the subform?
 

Users who are viewing this thread

Top Bottom