Results 1 to 6 of 6
  1. #1
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273

    Print a specific record

    I'm working on an inventory db, and am having several problems with coding, which I am pretty new at. I'll start with this problem, and continue my search for answers to the other problems while waiting for advice.

    I'm currently working on a form for the user to see or enter part information. This form (InventoryDetailed) is tied to the Inventory table through the qryInventory query, and has Indx (Autonumber) as a primary key. At the bottom of the form are 2 command buttons, Print Label and Save Record.

    The Save button works fine, as all it does is close the form, and the record is automatically saved. The problem I am having is how can I get the Print Label button to show a report of the record that the user just typed in, but is not yet saved to a table? If this button is clicked, the form should close, and the report should open.

    Another potential problem, this form is also used to view detailed information on records that are already in the table. A new undamaged label may need to be printed for a part already in inventory.

    Thanks again for all of your help, past, present and future.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can use this to force the record to save before printing:

    DoCmd.RunCommand acCmdSaveRecord

    If you need a method to print only the displayed records, I use this a lot:

    http://www.baldyweb.com/wherecondition.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    Thanks for the response. This is saving to the table now, and I did use the "Where" method to display the correct report, but now I get a run-time error '2497': The action or method requires a report name argument. Here's the code...

    Private Sub CmdPrtLbl_Click()
    Dim strFrm As String
    Dim varID As Integer
    strFrm = "frmInventoryDetail"
    varID = Me!Indx

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport rptTireLabel, acViewPreview, , "[Indx] = " & varID

    End Sub

    I don't know enough about code to decipher the problem. Most of what I've learned about VB is from these posts, so maybe I'm using things out of context. Any more advise?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Like many, the report name is a string argument. You could use a variable like that, but the actual report name has to be in quotes:

    DoCmd.OpenReport "rptTireLabel", acViewPreview, , "[Indx] = " & varID
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    NISMOJim is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    273
    Works perfectly, thank you. Glad it was such an easy fix. I'll post my next question in a new thread.
    Thanks again.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. specific record output to .pdf
    By REBBROWN in forum Reports
    Replies: 1
    Last Post: 09-25-2010, 07:35 AM
  2. print a specific report
    By cvolkers in forum Reports
    Replies: 4
    Last Post: 09-13-2010, 11:38 PM
  3. Text Box to show specific record
    By chu3w in forum Forms
    Replies: 1
    Last Post: 04-01-2010, 12:23 PM
  4. specific record
    By thewabit in forum Access
    Replies: 8
    Last Post: 02-17-2010, 11:32 PM
  5. Print a specific record report from a form
    By cynthiacorley in forum Reports
    Replies: 27
    Last Post: 02-08-2010, 06:34 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