Instead of :
Code:
MyPath = "C:\TestFolder\" & Me.Client_Name
If Dir(MyPath) = "" Then
MkDir (MyPath)
End If
I used:
Code:
On Error Resume NextMkDir MyPath
On Error GoTo 0
My final Code
Code:
Private Sub Command72_Click()
Dim MyFilter As String
Dim MyPath As String
Dim MyFilename As String
Dim strTimeStamp As String
MyFilter = "[Invoice#] = '" & [Forms]![Job List (New Job) Form]![Invoice#] & "'"
MyPath = "C:\TestFolder\" & Me.Client_Name
On Error Resume Next
MkDir MyPath
On Error GoTo 0
strTimeStamp = Format(Now(), "mm_dd_yyyy___@hh_mm")
MyFilename = "Invoice#" & Me.Invoice_NO_ & "_" & strTimeStamp & ".pdf"
Debug.Print MyPath
Debug.Print MyFilename
DoCmd.OpenReport "Final Invoice Report", acViewPreview, , MyFilter
DoCmd.OutputTo acOutputReport, "Final Invoice Report", acFormatPDF, MyPath & "\" & MyFilename, True
DoCmd.Close acReport, "Final Invoice Report"
End Sub
Thank you everyone for your help, I used bits and pieces from everyone and got exactly what I needed, thanks alot !!!!