Code to Print Report to PDF

Tophan

Registered User.
Local time
Today, 15:15
Joined
Mar 27, 2011
Messages
389
I'm having trouble with my print button code on my form. I want to print directly to pdf and save in a particular folder. The problem is it is printing ALL the records instead of the focus record. I would greatly appreciate if someone could tell me where I'm going wrong...below is the code

Code:
Private Sub cmdPrint3_Click()
Dim FileName As String
Dim FilePath As String
Dim strWhere As String

    If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
        MsgBox "Select a record to print"
    Else
        strWhere = "[CVINo] = " & Me.[CVINo]
End If
FileName = "The Sands CVI No" & Me.CVINo
FilePath = "C:\Users\reva.harrison\" & FileName & ".pdf"
DoCmd.OutputTo acOutputReport, "rptCVI", acFormatPDF, FilePath
MsgBox "CVI has been successfully created", vbInformation, "Create CVI"
End Sub
 
Thank you :)
 

Users who are viewing this thread

Back
Top Bottom