Microsoft KB Archive/209560

= ACC2000: How to Print a Single Record from a Form in a Report =

Article ID: 209560

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209560



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to select a single record on a form and to print it in a report.



MORE INFORMATION
The following procedure prints only the record that you select from the Customers form in the sample database Northwind.mdb.

 Create a report based on the Customers table, and then name it rptPrintRecord.  Open the Customers form in Design view. Add a command button to the form, and then set the following command button properties:   Name: cmdPrintRecord Caption: Print Record OnClick: [Event Procedure]   Set the OnClick property to the following event procedure: Private Sub cmdPrintRecord_Click

Dim strReportName As String Dim strCriteria As String strReportName = "rptPrintRecord" strCriteria = "[CustomerID]='" & Me![CustomerID] & "'" DoCmd.OpenReport strReportName, acViewPreview,, strCriteria End Sub  Open the form in Form view, and then click Print Record. Note that the report preview is limited to the current record from the Customer form.

Additional query words: one

Keywords: kbhowto kbinfo KB209560

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.