troubleshooting Question

Ms Access "If Dir function, Then, Else, End if"

Avatar of sheng wee
sheng wee asked on
Microsoft AccessVBA
6 Comments1 Solution116 ViewsLast Modified:
Yesterday it was working just fine. and somehow today I re-test the folder was empty but the pdf was saved version 2.

filename = Me.Ref_Number
filepath = "T:\ACCESS DATABASE\" & filename & "\Commercial\" & filename & ".pdf"

filename2 = Me.Ref_Number & "(v2)"
filepath2 = "T:\ACCESS DATABASE\" & filename & "\Commercial\" & filename2 & ".pdf"

If Dir("T:\ACCESS DATABASE\" & filename & "\Commercial\" & filename & " .pdf", vbDirectory) <> "" Then
DoCmd.OutputTo acOutputReport, "OrderCustomerReport", acFormatPDF, filepath
MsgBox "Quotation has been saved successfully", vbInformation, "Save Confirmed"
Application.FollowHyperlink "T:\ACCESS DATABASE\" & Me.Ref_Number & "\Commercial"
Else
DoCmd.OutputTo acOutputReport, "OrderCustomerReport", acFormatPDF, filepath2
MsgBox "Quotation(v2) has been saved successfully", vbInformation, "Save Confirmed"
Application.FollowHyperlink "T:\ACCESS DATABASE\" & Me.Ref_Number & "\Commercial"
End If

Did I missed out anything?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros