Pdf output

Vish69

New member
Local time
Today, 22:46
Joined
Sep 10, 2012
Messages
8
Hi,

I am creating a report in access 2007 using different queries from my datatbase. I want the reports for individual ID in a pdf format with the out file named as ID.pdf. So I want different individual pdf outputs for all my ID.Can anyone help me with this????

TIA
 
I found some code that I changed a little to fit my needs.
You should be able to use this, may be with a few changes.

This is the code that I have behind a button:

Code:
   On Error GoTo ErrorHandler

    Dim MySaleNumber As String
    Dim MyFilter As String
    Dim MyPath As String
    Dim MyFilename As String

    MySaleNumber = Str(Me.SE_SaleNumber)
    MyFilter = "[SE_SaleNumber]=" & Me!SE_SaleNumber
    MyPath = DLookup("SM_Datapath", "tblSystem")
    MyFilename = "Invoice.pdf"
    MyFilename = "Invoice" & MySaleNumber & ".PDF"

    DoCmd.OpenReport "rptInvoice", acViewPreview, , MyFilter
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False

    'Close our previewed report
    DoCmd.Close acReport, "rptInvoice"

ExitHandler:
    Exit Sub

ErrorHandler:
    Select Case Err
    Case 2501
        Exit Sub
    Case Else
        MsgBox Err.Number & " - " & Err.Description, vbCritical, "cmdClose()"
        Resume ExitHandler
    End Select


Catalina
 
Thanx Catalina for the suggestion.
I am running the below codes. Can you tell me what wrong I am doing??? I am not able to view the output pdf files.

Public Sub Command0_Click()
DoCmd.SetWarnings False

Dim rs As DAO.Recordset
Dim strAttachPath As String
Dim strAttachPath2 As String

Set rs = CurrentDb.OpenRecordset("select ID_Number from Cross_Reference")
If rs.RecordCount <> 0 Then
rs.MoveFirst
While Not rs.EOF

On Error GoTo Command0_Click_Err

DoCmd.RunMacro "Macro1", , ""

strAttachPath = "D:\Multiple_Histories\"
strAttachPath2 = "Multiple_Histories" & rs!ID_Number & ".pdf"

DoCmd.OutputTo acOutputReport, "History Table", acFormatPDF, strAttachPath & strAttachPath2, False, , , acExportQualityScreen
rs.MoveNext
Wend
End If
rs.Close
Set rs = Nothing
Command0_Click_Exit:
Exit Sub
Command0_Click_Err:
MsgBox Error$
Resume Command0_Click_Exit
End Sub
 

Users who are viewing this thread

Back
Top Bottom