Results 1 to 8 of 8
  1. #1
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159

    How to print a single Record's report?

    I have a feeling this question may have surfaced on this forum before.



    What I am in the process of doing is having a button feature on a form. Once clicked, it will print the corresponding report for whatever record you were viewing in Form View.

    I have taken a stab at some VBA code (I googled around, and copied some code) and I get a message like so:

    "Run-time error '2497':
    The action or method require a Report Name argument."

    Anyone know what this could be?

    Here is the code:
    Private Sub Print_Report_Click()
    Dim Master_Report As String
    Dim strCriteria As String

    strCriteria = "ID = " & Me.ID
    rptName = "Master_Report"
    DoCmd.OpenReport Master_Report, acViewPreview, , strCriteria

    End Sub

    --------
    Where Master_Report is the name of the report, and ID refers to the ID of the record I am currently viewing in Form View.
    Last edited by yes sir; 09-20-2010 at 12:54 AM. Reason: Because it is solved

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    the reason you're getting the error is because Access is trying to locate the string that is supposed to be supplied in the first argument of the docmd.openreport command and there isn't one. Since you have already assigned the variable "rptName" a string, replace that Master_Report argument that's current there with rptName and you'll be just fine.

    Access might also ask you to enclose the rest of the command after "OpenReport" in () because your first argument is a variable. That is common for Access to do.

  3. #3
    Join Date
    May 2010
    Posts
    339

  4. #4
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Ok, I ditched that code.

    I'm slowly getting more comfortable with the Macro Builder. I was able to use that to get it to work.

    RunCommand ---> Save Record
    OpenReport ---> Report Name: Used my report's name here, View: Print Preview, Where Condition: [ID]=[Forms]![use your Form's Name][ID]

  5. #5
    Join Date
    May 2010
    Posts
    339
    Glad it worked out for you.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So I guess you are ready to follow the link in my sig and mark this thread as Solved then, right?

  7. #7
    yes sir is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    159
    Quote Originally Posted by RuralGuy View Post
    So I guess you are ready to follow the link in my sig and mark this thread as Solved then, right?

    I have a history of marking all of my threads solved. No link necessary.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Expand entire row not just single cell in a Report
    By CityOfKalamazoo in forum Reports
    Replies: 2
    Last Post: 07-28-2016, 09:22 AM
  2. Print Single Record
    By stattech in forum Reports
    Replies: 5
    Last Post: 10-05-2010, 03:38 AM
  3. Printing a single report from form
    By OFA in forum Forms
    Replies: 9
    Last Post: 06-08-2010, 09:27 AM
  4. Print Single Envelope From Form
    By genest11 in forum Forms
    Replies: 2
    Last Post: 03-25-2010, 09:00 AM
  5. Print Single Report
    By emkwan in forum Access
    Replies: 1
    Last Post: 01-29-2010, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums