I have a simple database where a button (cmdPreviewReport) on the data entry form previews a report for the current record only. The code below (essentially that generated by the add command button wizard) works perfectly.

Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click

Dim stDocName As String
Dim strFilter As String

stDocName = "rptSites"
strFilter = "RecordID = Forms!frmSites!txtRecordID"
DoCmd.OpenReport stDocName, acPreview, , strFilter

Exit_cmdPreviewReport_Click:
Exit Sub

Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click

End Sub

My problem is in a more complicated database where the data source for the report is a query and the report itself contains numerous subreports (each sourcing different queries for their data).

Trying to add the filter to preview the current record only produces a report with no data and no subreports.

I've looked at the help section for the Open Report Action but am still none the wiser. Is it anything to do with the Filter Name argument?