Results 1 to 4 of 4
  1. #1
    koncreat is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43

    Printing current record

    I have a form that after a user fills out the fields they need to be able to print it, current record only. I have a created a button and written the code below for the on click property:

    Private Sub Command16_Click()
    DoCmd.OpenReport "current_issue", acViewPreview, , "[ID] = " & Me.ID

    Dim stDocName As String
    stDocName = "current_issue"
    DoCmd.OpenReport stDocName, acPreview
    Exit_Command16_Click:
    Exit Sub
    Err_Command16_Click:
    MsgBox Err.Description


    Resume Exit_Command16_Click
    End Sub


    The problem I have is that after they fill out the form and click the button the report comes up blank on the screen. If they close the form and open it and go to the record they want to print it works. Any help is greatly appreciated!

  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,518
    You're opening it twice, only the first time would be filtered. In any case, it sounds like you need to save the record first:

    If Me.Dirty Then Me.Dirty = False
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    koncreat is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2015
    Location
    U.S.
    Posts
    43
    I can't believe I didn't see that. I added your code and it works. Thank you!!

  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,518
    Happy to help!
    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. Replies: 19
    Last Post: 01-06-2018, 08:56 PM
  2. Replies: 7
    Last Post: 01-04-2018, 06:35 PM
  3. Replies: 8
    Last Post: 07-23-2017, 02:04 PM
  4. Replies: 7
    Last Post: 02-18-2015, 12:07 PM
  5. Replies: 4
    Last Post: 02-17-2015, 06:49 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