Results 1 to 8 of 8
  1. #1
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28

    Print current record, open printer dialog box

    I want to put a print button on my data entry form that prints the current record in a report that is laid out all nice and pretty.

    I found this code that works, but it goes straight to the printer - it does not bring up the printer dialog so you can select a printer.



    Code:
    Private Sub RecordPrint_Click()
        Dim strWhere As String
        If Me.Dirty Then
            Me.Dirty = False
        End If
        If Me.NewRecord Then
            MsgBox "Click cancel and open a member card."
        Else
            strWhere = "[ID] = " & Me.[ID]
            DoCmd.OpenReport "MemberDetail", acViewNormal, , strWhere
        End If
    End Sub
    How do I get it to bring up the printer dialog?

    .

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Untested, but did you try
    DoCmd.OpenReport "MemberDetail", acPreview, , strWhere

  3. #3
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28
    Just tried it. Does the same thing... acPreview opens the 'pretty' report in a preview tab, acNormal sends it straight to the printer.

    Still not getting a printer dialog

  4. #4
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28
    dang.

    acPreview and acViewPreview open the "pretty" form in a preview window.
    acPrint, acPrintOut, acNormal and acViewNormal send it straight to the printer - no printer dialog.

    guess I'll just go with what I've got. Would be nice to be able to select a different printer, though

    Code:
    Private Sub cmdMemberPrint_Click()
        Dim strWhere As String
        If Me.Dirty Then
            Me.Dirty = False
        End If
        If Me.NewRecord Then
            MsgBox "Click Ok and open a member card."
        Else
            strWhere = "[ID] = " & Me.[ID]
            DoCmd.OpenReport "MemberDetail", acPrintOut, , strWhere
        End If
        DoCmd.RunCommand acCmdSaveRecord
        DoCmd.Close
    End Sub

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    With Access, there is not a built in way to access those DLL files. You need to create your own Dialog Box via VBA. Here is some info on it.
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    and another example plus a couple more ideas
    https://www.accessforums.net/program...ing-43166.html

  6. #6
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28
    Thank you ItsMe. I appreciate your reply.

    That's a little more work than I want to do for a freebie LOL - but thank you. It prints the record Ok, and the users won't have but one printer in the office anyway.... I wanted it mainly for myself so I could print to a PDF file.

    It's all good. I love my little database

  7. #7
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I usually have two buttons - one for "Print" which prints directly to the default printer and one for "Print Preview" which will bring up the report in preview mode, from there I can print it to pdf if I choose.

  8. #8
    Jamesiv1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    28
    Quote Originally Posted by aytee111 View Post
    I usually have two buttons - one for "Print" which prints directly to the default printer and one for "Print Preview" which will bring up the report in preview mode, from there I can print it to pdf if I choose.
    aaahhhh..... yes. Didn't think about that. The acViewPreview is opening up in a new tab, but I can make it a popup window, yes?

    That will work nicely!

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

Similar Threads

  1. Print Report from Current Record
    By hnkford in forum Reports
    Replies: 15
    Last Post: 05-22-2015, 08:08 AM
  2. Open Print Dialog when Report is opened
    By tylerg11 in forum Reports
    Replies: 1
    Last Post: 01-09-2014, 10:44 AM
  3. How can I print an object for the current record?
    By alexandervj in forum Access
    Replies: 3
    Last Post: 12-06-2013, 04:03 PM
  4. Print current record to a report
    By drawc in forum Access
    Replies: 2
    Last Post: 01-15-2012, 12:48 AM
  5. Replies: 5
    Last Post: 10-26-2011, 02:59 PM

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