Yes, FamilyID is a field in the underlying query of the report.
When I use the button now, I get the following error message:
"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables".
The FamilyID field is in the query. It is also on the report.
I don't know what I have done wrong. The form is a Tabbed form with subforms. The FamilyID field is on the Main form, and the second tabbed form. Does this make a difference?
Here is the code:
Private Sub PrintStat_Click()
On Error GoTo Err_PrintStat_Click
Dim stDocName As String
Dim stFilter As String
stDocName = "Stats-Current Family"
stFilter = "FamilyID = '" & Forms!FamilyTabbed!FamilyID & "'"
DoCmd.OpenReport stDocName, acViewPreview, , stFilter
DoCmd.PrintOut acPages, , , , 3
Exit_PrintStat_Click:
Exit Sub
Err_PrintStat_Click:
MsgBox Err.Description
Resume Exit_PrintStat_Click
End Sub