We help IT Professionals succeed at work.
Get Started

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

sheng wee
sheng wee asked
on
115 Views
Last Modified: 2017-05-08
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?
Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE