none
dlookup to take pdf to the correct folder RRS feed

  • Question

  • hi ,

    this is the code that this forum helped me with  but i need some help to modify it 

    this code looks at a table for the directory to put my reports in and all is good 

    but i really need is that this code looks as the table and selects the directory from a list 

    the table is below 

    C:\Users\User\Documents\Purchasing

    C:\Users\User\Documents\sales

    C:\Users\User\Documents\engineering 

    i do not want the directory in the code just the location but using the ID as the reference if that is possible 

    i have no experience of VBA  so any help appreciated 


      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 & "\" & ME.CustomerName & " " & Me.Invoicenumber & ".pdf"
              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
            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

    steve



    Sunday, February 8, 2015 7:13 AM

All replies

  • hi ,

    will i still see any replies to this question  where this thread is now , or where do i look

    steve

    Monday, February 9, 2015 1:24 AM