Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

Summary

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

↑ Back to the top


More information

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

  1. Create a report based on the Customers table, and then name it rptPrintRecord.
  2. 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]
    					
  3. 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
    					
  4. 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.

↑ Back to the top


Keywords: KB209560, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 209560
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 313