Results 1 to 8 of 8
  1. #1
    gabrielr is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    4

    View instead of print

    Hi all,



    I have a Report, that gets populated (in part at least) by data passed to the report_Load() subroutine. The report is launched from a form, with a command button:

    Code:
    DoCmd.OpenReport reportName:="Report1", OpenArgs:=argsStr
    However, instead of launching the report to view, it trys to print it right away! How do I get it to preview the report, and not print

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    If you look in help at OpenReport, you'll see there's an argument that controls that. You haven't included it, and the default is to print.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    gabrielr is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    4

    Hmm

    I tried what you suggested, and found that acViewReport previewed the report without printing it. However, it also refuses to read the Detail_Format subroutine, and I need that to change the colors of the fonts used based on another variable -

    Code:
    Option Compare Database
    
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
    On Error GoTo Detail_Format_Error
    
        Dim WasSold As Boolean
        Dim shadedColor As String
        
        WasSold = Check37.Value
        
        shadedColor = "#000000"
        If (WasSold) Then
            shadedColor = "#0072BC"
        End If
        
        Me.Section(acDetail).BackColor = shadedColor
        
        MsgBox "Alert alter!"
        
    Detail_Format_Exit:
        Exit Sub
    
    Detail_Format_Error:
        MsgBox "Error " & Err.Number & ": " & Err.Description
        Resume Detail_Format_Exit
        
    End Sub
    But the subroutine is never called.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You want Preview mode, not Report. I think it's acViewPreview. The format events don't fire in Report mode, as you've found (that drove me crazy the first time I ran into it).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    gabrielr is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    4
    Thanks pbaldy - the only problem is that I also have to set the row source, and you can't do that in acViewPreview.

    The way I'm doing my code is like so:

    Form - ReportGenerator
    - Has fields to limit report by date, type, etc
    - on ReportGenerator.CommandButton1.onClick
    - Create string with values (ie 11-02-1999|||true|||true|||etc...)
    - DoCmd.OpenReport "MyReport", acViewPreview, , , stringWithArgs

    MyReport
    - on_load: read string, generate sql string, set row source of report to sql value
    - format: read single value, change background color of row based on boolean value, provided by a checkbox on the report that is A) not visible and B) boung to the boolean value in the query

    Am I going about this wrong? My goal is to have a form that lets you set the limits (or filter) a report - that report then has to have different colors for different rows based on a field bound to the report query.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I'm sure you can set the record source ( I assume that's what you meant) in preview mode. Try the open event rather than the load event. That's where I do it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    gabrielr is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    4

    Solved!

    Ahh, that did the trick! Just had to change

    Report1_load to Report1_open

    Thanks pbaldy!

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problemo, and welcome to the site by the way!
    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: 5
    Last Post: 10-26-2011, 02:59 PM
  2. Replies: 10
    Last Post: 07-25-2011, 12:07 PM
  3. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  4. Replies: 1
    Last Post: 10-24-2010, 11:32 AM
  5. cmd to print/view an MS-Excel file
    By gkast in forum Forms
    Replies: 0
    Last Post: 11-23-2008, 07:39 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