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

Article translations Article translations
Article ID: 98801 - View products that this article applies to.
This article was previously published under Q98801
Moderate: Requires basic macro, coding, and interoperability skills.

Expand all | Collapse all

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 (or Nwind.mdb in earlier versions).
  1. Create a report based on the Customers table and name it rptPrintRecord.
  2. Create the following macro and save it as mcrPrintRecord:

    NOTE: The expression in the OpenReport event is refering to the CustomerID field of the customer's form.

    In Microsoft Access 97:
             Macro Name       Action
             -----------------------------
             mcrPrintRecord   RunCommand
                              OpenReport
    
             mcrPrintRecord Actions
             --------------------------------------------------------------
             RunCommand
                Command: Save Record
    
             OpenReport
                Report Name: rptPrintRecord
                View: Print Preview
                Where Condition: [CustomerID]=Forms![Customers]![CustomerID]
    						
    In Microsoft Access 7.0:
             Macro Name       Action
             -----------------------------
             mcrPrintRecord   DoMenuItem
                              OpenReport
    
             mcrPrintRecord Actions
             --------------------------------------------------------------
             DoMenuItem
                Menu Bar: Form
                Menu Name: Records
                Command: Save Record
    
             OpenReport
                Report Name: rptPrintRecord
                View: Print Preview
                Where Condition: [CustomerID]=Forms![Customers]![CustomerID]
    						
    In Microsoft Access 1.x and 2.0:
             Macro Name       Action
             ---------------------------
             mcrPrintRecord   DoMenuItem
                              OpenReport
    
             mcrPrintRecord Actions
             --------------------------------------------------------------
             DoMenuItem
                Menu Bar: Form
                Menu Name: File
                Command: Save Record
    
             OpenReport
                Report Name: rptPrintRecord
                View: Print Preview
                Where Condition: [CustomerID]=Forms![Customers]![CustomerID]
    					
  3. Open the Customers form in Design view. Add a command button to the form and set the following command button properties:

    In Microsoft Access 2.0, 7.0, and 97:
             Name: cmdPrintRecord
             Caption: Print Record
             OnClick: mcrPrintRecord
    						
    In Microsoft Access 1.x:
             ControlName: cmdPrintRecord
             Caption: Print Record
             OnPush: mcrPrintRecord
    					
  4. Open the form in Form view, and then click the Print Record button. Note that the report contains only the current record from the Customer form.

Properties

Article ID: 98801 - Last Review: January 18, 2007 - Revision: 2.1
APPLIES TO
  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
Keywords: 
kbfaq kbhowto KB98801
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com