none
stop showing pdf report just put it in folder RRS feed

  • Question

  • hi , 

    this vba  creates 3  pdf report  shows them to me and then puts it in a folder 

    how can it be changed that it does not show me the reports but just puts them into the folder 

    thanks 

    steve

    Private Sub cmdPDF_Click()
    
      On Error GoTo Err_Handler
        
        Const FOLDER_EXISTS = 75
        Const MESSAGE_TEXT1 = "No current invoice."
        Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
        Dim strFullPath As String
        Dim varFolder As Variant
        
       If Not IsNull(Me.Invoicenumber) Then
            ' build path to save PDF file
          
            varFolder = DLookup("Folderpath", "pdfFolder")
            If IsNull(varFolder) Then
                MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
            Else
                ' create folder if does not exist
                varFolder = varFolder & "\" & Me.CustomerName
                MkDir varFolder
               
              strFullPath = varFolder & "\" & "Invoice No" & " " & Me.Invoicenumber & ".pdf"
              
                ' ensure current record is saved before creating PDF file
                Me.Dirty = False
                DoCmd.OutputTo acOutputReport, "Invoice report", acFormatPDF, strFullPath, True
             
             
             strFullPath = varFolder & "\" & "C of C  No" & " " & Me.Invoicenumber & ".pdf"
              
                ' ensure current record is saved before creating PDF file
                Me.Dirty = False
                DoCmd.OutputTo acOutputReport, "C OF C report", acFormatPDF, strFullPath, True
            
             strFullPath = varFolder & "\" & "Despatch No" & " " & Me.Invoicenumber & ".pdf"
              
                ' ensure current record is saved before creating PDF file
                Me.Dirty = False
                DoCmd.OutputTo acOutputReport, "Invoice delivery note", acFormatPDF, strFullPath, True
            
            
            
            End If
        Else
            MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
        End If
    
    Exit_Here:
        Exit Sub
        
    Err_Handler:
        Select Case Err.Number
            Case FOLDER_EXISTS
            Resume Next
            Case Else
            MsgBox Err.Description
            Resume Exit_Here
        End Select
    
    End Sub

    Tuesday, February 10, 2015 6:06 AM

All replies

  • The argument True in

                DoCmd.OutputTo acOutputReport, "Invoice report", acFormatPDF, strFullPath, True

    and in

                DoCmd.OutputTo acOutputReport, "Invoice delivery note", acFormatPDF, strFullPath, True

    means "open the output after it has been created". Change it to False to avoid that. If you omit this argument altogether, Access will use False. For example:

                DoCmd.OutputTo acOutputReport, "Invoice delivery note", acFormatPDF, strFullPath


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, February 10, 2015 6:39 AM