docmd.outputto gives error and works incomplete (1 Viewer)

so10070

Registered User.
Local time
Today, 20:38
Joined
Aug 18, 2016
Messages
51
Starting with a click on a button to open a report gives error 2046 (Run-time error 2046 the command or action 'OutputTo' isn't available now).

  1. When I put a button (_Click) on a separate form called by the previous form, my report opens without any problem.
  2. When I put the command lines in the opening procedure of loading procedure of the second form (to prevent a button apearing) then my report gives this error.
Compiling the code offers no solace.

Code:
DoCmd.OutputTo acOutputReport, "rptMyReport", acFormatPDF, strPadNameFileName, True

I work with direct path names (\\Antwerp\ ...). When starting this command and placing the report on the desktop then the report opens as a pdf. When I'm trying to place this report on the serverpath, and as mentioned above, starting it from an additonal form, then the pdf isn't opening.

What can be the problem. :(
 

Minty

AWF VIP
Local time
Today, 19:38
Joined
Jul 26, 2013
Messages
10,371
Can we see all the code, including the creation of the file path. The bit you've shown should work, so it must be something else.
 

so10070

Registered User.
Local time
Today, 20:38
Joined
Aug 18, 2016
Messages
51
Here

Code:
Private Sub cmbPDF_Click()
    Dim strPadNaamBestandsNaam As String
    Dim txtOutPutFile As String
    Dim strCodeModule As String

    strCodeModule = "frmPDF cmbPDF_Click"

    On Error GoTo foutafhandeling

'    'Opening report here
    DoCmd.OpenReport "rptPerScholenProcenten", acViewPreview, , , acDialog

'    'Output to pdf
    If TempVars.Item("SO_NummerPDF") = "" Or IsNull(TempVars.Item("SO_NummerPDF")) Then
        'error if SO_nummer is empty or NULL
        info 5
    Else
        '4. Make path and file name
        strPadNaamBestandsNaam = """" & TempVars.Item("SO_SamengesteldPDF") & "\" & TempVars.Item("SO_NummerPDF") & "_" & Format(Date, "yymmdd") & ".pdf" & """"

        DoCmd.OutputTo acOutputReport, "rptPerScholenProcenten", acFormatPDF, strPadNaamBestandsNaam, True
    End If

    DoCmd.Close acReport, "rptPerScholenProcenten"
    DoCmd.Close acForm, "frmPDF"
    DoCmd.OpenForm "frmKnoppenBegin", , , , , acDialog

Exit_Sub:
    Exit Sub

foutafhandeling:
    Call FoutenRegistratie(Err.Number, Err.Description, strCodeModule, Environ("Username"))
    Resume Exit_Sub
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:38
Joined
May 7, 2009
Messages
19,230
remove the double qoute before and after the pathname
 

so10070

Registered User.
Local time
Today, 20:38
Joined
Aug 18, 2016
Messages
51
Found the problem. Is problem of Microsoft and not mine! Whew! :) See http://www.utteraccess.com/forum/index.php?showtopic=2035785 for some workarounds. The problem lies in one of the arguments of the openreport commando. First I wrote this line:
Code:
DoCmd.OpenReport "rptPerScholenProcenten", acViewPreview, , , acDialog
"acDialog" gives the problem. It must be:
Code:
DoCmd.OpenReport "rptPerScholenProcenten", acViewPreview, , , [B][U]acWindowNormal[/U][/B]
And everithing is normal.
 

Users who are viewing this thread

Top Bottom