Discussion Locked

Access Reports and Forms

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I print one record using a pre-defined report from a button I've created on a form. The record I want is shown on the report. Access Help gives an answewr, but it doesn't matter how many times I try it don't work !! (You know [fieldname]= FORMS![formname]![fieldname] )

Is there something missing ?

5 replies

by duppypog

Your form should have a field that uniquely identifies that record. In the underlying query for the report, the parameter criteria should point to that field - like this:
[Forms]![frmMyFormName]![txtFieldname]
This tells the query to get the parameter from the form field to return that specific record.
Your button on the form just needs to either print preview the report, or print it.

Hope this helps-
Lynnette

by john_wills

The previous answer should work, but I don't like it because it insists that the nested program(the report in this case) know what is nesting it, very unmodular. The structure I use for this kind of work is this:
Private Sub PrintClientInformation_Click()
DoCmd.OpenReport "rptClientInformation", acPreview, , "[ClientID]=" & Me.ClientID
End Sub
However, there may well be, as you suggest, something missing from your call, dependent perhaps on something in your form, although I cannot think what.

This discussion is closed to new replies.