Results 1 to 5 of 5
  1. #1
    SGrohola is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2017
    Location
    Romulus, MI
    Posts
    41

    Question Help with additional coding needed to only print 1 page of report.

    I have the following code set up to open a report in print preview. I want to add coding to it to only print the first page though. Can anyone help?



    Code:
    Private Sub cmdvwandprnt_Click()
            Dim strWhere As String
        
        If Me.Dirty Then 'save any edits.
            Me.Dirty = False
        End If
        
        If Me.NewRecord Then 'Check there is a record to print
            MsgBox "Select a record to Print"
        Else
            strWhere = "[ID] = " & Me.ID
            DoCmd.OpenReport "rpt_Owner Operators", acViewPreview, , strWhere
        End If
    End Sub

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    try something like

    DoCmd.OpenReport "rpt_Owner Operators", acViewPreview

    DoCmd.PrintOut acPages, 1, 1
    DoCmd.Close acReport, "rpt_Owner Operators, acSaveNo

  3. #3
    SGrohola is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2017
    Location
    Romulus, MI
    Posts
    41
    It's working where, it's only printing one page, but is there any way to change it, so that it prints to .pdf file, as the preview doesn't even show to be able to change it.

    Thank you!

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    it should be, try something like this:

    http://www.tek-tips.com/viewthread.cfm?qid=1711684

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Found this online, similar to what rpeare provided, maybe you can use some of it. I tried using your report name.

    Dim myPath As String
    Dim strReportName As String

    DoCmd.OpenReport "rpt_Owner Operators", acViewPreview
    DoCmd.PrintOut acPages, 1, 1 '(Added this from rpeare post)

    myPath = "C:\Documents and Settings"
    strReportName = "rpt_Owner Operators.pdf"

    DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
    DoCmd.Close acReport, "rpt_Owner Operators"

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

Similar Threads

  1. Replies: 1
    Last Post: 11-18-2016, 08:36 AM
  2. Replies: 1
    Last Post: 11-11-2016, 07:02 PM
  3. Replies: 10
    Last Post: 06-19-2014, 01:51 AM
  4. How do I not print a page in a report
    By SFC in forum Reports
    Replies: 3
    Last Post: 08-15-2012, 11:47 AM
  5. Replies: 3
    Last Post: 08-07-2011, 09:22 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