how to create command button on form that when clicked print previews form for current record

Posted on 2011-10-25
Last Modified: 2013-04-11
How can I create a macro to attach to a command button that will print preview only the current record? I can use the button wizard but it prints, doesn't allow me to print preview. I want to create a button that when the user clicks on it - it just previews the current form. thanks! Or if not a macro, some other way?

Question by:agwalsh
    LVL 61

    Accepted Solution

    Use VBA in the Click Event:

    Docmd.OpenReport "YourReportName", acViewPreview,, "[IDFieldName]  = " & Me.IDField
    LVL 61

    Expert Comment

    In explanation, that opens your report, filtering it to a particular ID, based on the ID that is currently showing on your form.

    Author Comment

    Will this work for a form as well? Just to change OpenReport to OpenForm?

    Author Closing Comment

    Worked like a dream! Thank you !!1

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now