Print Report for One Record

  • Thread starter Thread starter dficks
  • Start date Start date
D

dficks

Guest
Hi, I have a form that shows detailed data from one contact record. I would like to be able to create a report that accesses the data from just this one record and have a button that allows a user to print it from within that form. I've tried a number of things but keep ending up with a report for all the records. I appreciate any help - even if its direction to a posting which previously discussed this!
 
You need to add the Where Condition to the OpenReport Statement.

Docmd.OpenReport "YourReportName",,,"YourRecordNumberField="Str(YourForm'sTextFieldThatHasTheRecordYouWant)

Try that...
 
Or you could create a command button then put this code on the onclick event of the button.

Private Sub command button name_Click()
On Error GoTo Err_Command48_Click
Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "your report name"
strLinkCriteria = "[the unique key field] = Forms![form name]![the unique key field]"

DoCmd.OpenReport strDocName, acNormal, , strLinkCriteria

Exit_command button name_Click:
Exit Sub

Err_command button name_Click:
MsgBox Err.Description
Resume Exit_command button name_Click

End Sub

You will need to put a save button and save the record before printing.

[This will print report of that record direct from the form]

HTH
Andy
 
Last edited:

Users who are viewing this thread

Back
Top Bottom