Is the folder always the same or do you want a Open File Dialog to open and then you choose folder? Is file name always the same as REQUEST NO? And always .pdf?
Thanks for replying..
I don't need a form to ask me to browse for folder. The folder path will be always the same and way of naming files is inside that folder will always be the same (like request number; 5-digits name...). In that folder I will have ONLY PDFs.
Then I suggest using Allen Browne's functions to check if file exist and then use Application.FollowHyperlink to open it or display a label on form with note that it doesn't exist.
I was unable to solve it via Allen Brown's functions, but, this could be helpfull to me:
Private Sub Label8_Click()
If Len(Dir("C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests\22556.pdf")) = 0 Then
MsgBox "This file does NOT exist."
Else
MsgBox "This file does exist."
End If
End Sub
This way I can see does the file exist in my folder and if it does, I can browse the folder manually and open the file inside it... As you can see above, the formula works only for 22556.pdf but I would like it to work for whichever request I put in REQUEST NO field. How can I do that?
I don't know what problems could you possibly have with Allen Browne's functions, all is explained in comments there. But anyway, if you'd like to follow this path:
Code:Private Sub Label8_Click() Dim sFileName As String sFileName = "C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests" & Me![REQUEST NO] & ".pdf" If Len(Dir(sFileName)) = 0 Then MsgBox "This file does NOT exist." Else Application.FollowHyperlink sFileName End If End Sub
Ah yes, sorry, backslash missing in path:
sFileName = "C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests\" & Me![REQUEST NO] & ".pdf"
Thank you so much! It works perfect!!
You're welcome