Results 1 to 9 of 9
  1. #1
    miicker is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    18

    Run-time error "2585" while trying to export to PDF

    Hello everyone,



    I have a strange problem. I'm trying to run the following code:
    Code:
    If rpNameNu <> rpName Then    Me!KnopPrint.Visible = False
        Me!KnopPDF.Visible = False
        Me!KnopSent.Visible = False
        DoCmd.OutputTo acOutputReport, rpNameNu, acFormatPDF, , no, , , acExportQualityPrint
    End If
    This needs to run a second after the report is open. But when I insert the code into On Load property, or the On Open property it won't work
    Simply because the report is not jet open..

    When I put the code in the On Current property, and open the report, and click somewhere random, the code does work!

    Does someone know how I can let it run smooth?

    I also tryed these functions to delay the export to pdf functionality:
    Code:
    Option Compare Database
    
    Public Function Pause(NumberOfSeconds As Variant)
        On Error GoTo Error_GoTo
    
    
        Dim PauseTime As Variant
        Dim Start As Variant
        Dim Elapsed As Variant
    
    
        PauseTime = NumberOfSeconds
        Start = Timer
        Elapsed = 0
        Do While Timer < Start + PauseTime
            Elapsed = Elapsed + 1
            If Timer = 0 Then
                ' Crossing midnight
                PauseTime = PauseTime - Elapsed
                Start = 0
                Elapsed = 0
            End If
            DoEvents
        Loop
    
    
    Exit_GoTo:
        On Error GoTo 0
        Exit Function
    Error_GoTo:
        Debug.Print Err.Number, Err.Description, Erl
        GoTo Exit_GoTo
    End Function
    and:
    Code:
    Option Compare Database
    Option Explicit
    Private Declare Sub sapiSleep Lib "kernel32" _
            Alias "Sleep" _
            (ByVal dwMilliseconds As Long)
    Sub sSleep(lngMilliSec As Long)
        If lngMilliSec > 0 Then
            Call sapiSleep(lngMilliSec)
        End If
    End Sub
    Both without succes.

    Thanks in advance.

  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,521
    I would try doing the output from outside the report. If you think about it, while opening the report you try to output the report, which opens the report, which tries to output the report, which opens...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Yes, in whatever module is used to open the report, open it invisible. Next line should set the visibility of whatever KnopPrint is then make the report visible if it needs to be. Don't get the whole gist of the process though, because as far as I recall, you don't have to open a report to export it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  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,521
    Actually I was thinking you could leave the visibility stuff in the report, just move the output. You don't have to open it to export it, unless you want to open it with a wherecondition and export the filtered result.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    miicker is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Posts
    18
    The data in the report is variabel, so that's why it needs to be opened first

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Only if it's opened with a wherecondition rather than having criteria in the underlying query. If so, I'd still do it from outside, basically

    Open report hidden
    output to pdf
    close report

    Or use this instead of a wherecondition:

    Emailing a different report to each recipient

    so the filtering is done from within.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    miicker is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Posts
    18
    How can you open the report hidden and than export it to PDF?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Look at the arguments available for OpenReport; one lets you open it hidden.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Quote Originally Posted by miicker View Post
    The data in the report is variabel, so that's why it needs to be opened first
    don't know what this means. All reports are "variable" and depend on the query results. Even if filtered, I'm fairly certain you don't have to open it to export it.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-28-2015, 01:45 AM
  2. Replies: 1
    Last Post: 03-14-2013, 12:39 PM
  3. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  4. Replies: 4
    Last Post: 07-25-2012, 04:01 AM
  5. Replies: 2
    Last Post: 12-02-2010, 02:35 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