Create a marco within a form button that will use the item number to print the record that is on the screen

Posted on 2012-08-15
Last Modified: 2012-08-24
Create a marco within a form button that will use the item number to print the record that is on the screenCreate a marco within a form button that will use the item number to print the record that is on the screen.
Question by:frank_guess
    LVL 24

    Expert Comment

    Can we have some form of Sample workbook as a starting point.
    It would be very easy to create something that is not related to your requirements.
    LVL 30

    Expert Comment

    In VBA:
    ' this code prints a current record displayed in form
    Report name: Contract
    Form's control for contractID: contractID, [item Number] in your question.
    RecordSource field name: ContractID

    Private Sub btnPrintCurrent_Click()
        DoCmd.OpenReport "Contract", acViewPreview, , "[ContractID] = '" & Me!contractID & "'"
    End Sub
    LVL 30

    Expert Comment

    Macro: Macro1, forms' name:Contract, Button click event set to Macro1.
    Create macro: select relevant entries.

    Report Name: Contract
                   view: Print Preview
    Where Condition=     [Contracts]![contractID]  =[Forms]![Contract]![contractID]

    Author Comment

    I have a form that has a print button on the form, this is utilizing the automated feature of button creation (using the wizard).  I have two key fields one is called item number and one called Evidence bag number.
    I need to print the Chain of custody form with the form that I am setting on.
    So I need to know how to make the most of how to control single record printing.  I have a query where presently I can type in the Item number and it will print the information that is on the form.  But it brings up the printer screen and goes through all the stuff for printing.  What I need it to do is print the single record that I am setting on and not go through the entire process.  Got any ideals how to make the macro work correctly.

    Author Comment

    The print button has the on click with the following macro:
    Action - OpenReport
    RPT_Single_Evidence_Tracker_Rpt, Print Review, , , Normal

    How do I change this macro so it will fill in the item number from the item number on the form.
    LVL 30

    Accepted Solution

    Looks like a different version from 2010

    Try changing the click event to [Procedure]
    and add the following to the button click procedure

    DoCmd.OpenReport "Contract", acViewPreview, , "[ContractID] = '" & Me!contractID & "'"

    Open in new window

    Report Name: Contract  to "RPT_Single_Evidence_Tracker_Rpt"
    Table field name: [ContractID] to your [Item Number]
    Control name on form: contractID  to respective control name on your form

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now