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

Last reviewed: February 4, 1998
Article ID: Q98801
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

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

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

MORE INFORMATION

The following method explains how to print only the record 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:

          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. Notice that the report contains only the current record from the Customer form.


Additional query words: one
Keywords : FmsOthr kbusage kbfaq
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.