Printing with path name saved in a table

8

I created a table called Funcionarios where I have at least 2 fields:

ID and caminho_impressao .

Where I put it, for example:

  • C: \ Users \ user1 \ documents \
  • C: \ Users \ user2 \ documents \
  • So I tried to print a PDF of a report as follows:

    Dim FileNamePDF As String
    Dim SetDirectoryPDF As String
    Dim strRelatorio As String
    
    
    ' set directory to save to
    SetDirectoryPDF = DLookup("caminho_impressao", "Funcionarios", "ID=" & login.ID)
    
    'set the filename and save location
    strRelatorio = "Relatorio_mensal"
    'Tentei e não deu
    'FileNamePDF = SetDirectoryPDF & strRelatorio & ".pdf"
    FileNamePDF = CStr(SetDirectoryPDF) & strRelatorio & ".pdf"
    MsgBox FileNamePDF
    DoCmd.OutputTo acOutputReport, strRelatorio, acFormatPDF, FileNamePDF, False
    

    But I could not generate the file. The following error message appears:

    Question

    How can I deal with this particular error?

        
    asked by anonymous 08.01.2014 / 12:46

    1 answer

    4
    'Imprimir todos os relatórios
    
    Dim FileNamePDF As String
    Dim SetDirectoryPDF As String
    Dim strRelatorio As String
    
    'Tabela Funcionarios contem pelo menos os campos: ID, Nome, caminho_impressao
    SetDirectoryPDF = DLookup("caminho_impressao", "Funcionarios", "ID=" & login.ID)
    
    strRelatorio = "Orcamentos"
    FileNamePDF = SetDirectoryPDF & strRelatorio & ".pdf"
    DoCmd.OutputTo acOutputReport, strRelatorio, acFormatPDF, FileNamePDF, False
    
    strRelatorio = "Vendas"
    FileNamePDF = SetDirectoryPDF & strRelatorio & ".pdf"
    DoCmd.OutputTo acOutputReport, strRelatorio, acFormatPDF, FileNamePDF, False
    
    strRelatorio = "Contratos"
    FileNamePDF = SetDirectoryPDF & strRelatorio & ".pdf"
    DoCmd.OutputTo acOutputReport, strRelatorio, acFormatPDF, FileNamePDF, False
    
    MsgBox "Os arquivos foram salvos na pasta Bibliotecas\Documentos.", vbInformation, ""
    

    In path_print I define the path of each machine (employee), eg

    C:\Users\vendedor01\documents\
    

    In fact, the code was correct from before, but only corrected when I asked for 'Compress and Repair ...'

        
    06.02.2014 / 13:15