#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Aug 2012
    Posts
    28
    Rep Power
    0

    VB code to print only page 1


    Good day,

    I could sure use your help with the VB code to print only one page, the details are below:

    Report name: SHEMA Form

    Presently I have a button that uses the following code, but the report prints a duplicate page for each of the line items associated with the "Key" field, which is "PRNumTemp".

    Private Sub Command12_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 = "PRNumTemp = '" & Me.PRNumTemp & "'"
    DoCmd.OpenReport "SHEMA Form", acViewReport, , strWhere
    End If
    End Sub

    So if you have a good suggestion, I'm all ears, but at least provide the code for printing only one page, please and thank you.

    kableland
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Location
    Lake County, IL
    Posts
    865
    Rep Power
    152
    Here is a line of code I have used to print just one page of a report.

    Code:
    DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=Forms!frmClients!ID"
    ID is the control name in the report and references the control in my form that I want to print.

    I'm not sure what is causing your db to print twice.

    Alan
    Alan Sidman
    Office 2010, 2007, 2002

    If I helped you, then click "give rep" button in the lower left corner.
  4. #3
  5. Moderator
    ASP Super Genius (4500 - 4999 posts)

    Join Date
    Apr 2009
    Location
    The Great Land
    Posts
    4,620
    Rep Power
    650
    The duplication is probably because of the RecordSource. There are multiple tables? Is there one or more join clauses in the SQL statement? Is this query including more than one 'many' table joined to the 'one' table?

    Alan, might be a typo in your code sample as it has the variable within quote marks instead of concatenating. It does look like OP is trying to limit report to a single record by using unique value criteria.
    Last edited by June7; November 5th, 2012 at 09:04 PM.
    I like to know if my suggestion helped you. One way to let me know is by clicking star at bottom left corner of post.
    Debug!Debug!Debug!http://www.cpearson.com/excel/debug.htm

Similar Threads

  1. Page information on Print Page
    By mmltonge in forum HTML, JavaScript And CSS Help
    Replies: 1
    Last Post: April 28th, 2008, 02:22 PM
  2. How do i make a Print Button and Print the Page ??
    By tayhaithian in forum HTML, JavaScript And CSS Help
    Replies: 2
    Last Post: August 8th, 2007, 05:34 AM
  3. Print Page - SET Page Setup
    By misskaos99 in forum ASP Development
    Replies: 2
    Last Post: February 20th, 2007, 01:32 PM
  4. How to add a print page option on a page?
    By Zoe-Alyssa in forum ASP Development
    Replies: 4
    Last Post: December 8th, 2006, 05:42 PM
  5. I want to write code to print a web page
    By aspsandhya in forum .NET Development
    Replies: 1
    Last Post: April 26th, 2004, 11:22 AM

IMN logo majestic logo threadwatch logo seochat tools logo