ebbsamsung
Registered User.
- Local time
- Today, 08:48
- Joined
- May 22, 2014
- Messages
- 19
Dear Experts,
Good day!
I actually had a problem in my db. My boss want me to make a button in a subform detail to open specific pdf file based on path listed in table named "tblPDF" and concatenate a field DocumentNo in subform. I've done this part using the code i found in a forum. But now, my boss want as well if the pdf file not there, it will open the window explorer setfocus to the folder name identical to the DocumentNo.
Is is possible to please modify the code i found to fit the need of my boss?
I am very sorry, as a novice like i need your help for this matter.
I attached herein the screenshots of the table, form with subform and a directory folder.
Here is the code i used so far to open pdf file
Thank you in advance experts!
Good day!
I actually had a problem in my db. My boss want me to make a button in a subform detail to open specific pdf file based on path listed in table named "tblPDF" and concatenate a field DocumentNo in subform. I've done this part using the code i found in a forum. But now, my boss want as well if the pdf file not there, it will open the window explorer setfocus to the folder name identical to the DocumentNo.
Is is possible to please modify the code i found to fit the need of my boss?
I am very sorry, as a novice like i need your help for this matter.
I attached herein the screenshots of the table, form with subform and a directory folder.
Here is the code i used so far to open pdf file
Thank you in advance experts!
Code:
Private Sub cmdOpenPDF_Click()
Dim colFiles As New Collection
Dim direc As String
Dim filetosearch As String
filetosearch = Me.No & "_" & Me.DocumentNo & "_" & Me.RevisionNo & ".pdf"
direc = Nz(DLookup("PDFsFolder", "tblPDF", "PdfId = 14"), "")
RecursiveDir colFiles, direc, filetosearch, True
Dim vFile As Variant
For Each vFile In colFiles
OpenAnyFile (vFile)
Next vFile
End Sub
Function OpenAnyFile(strPath As String)
If FileThere(strPath) Then
MsgBox ("Open PDF file for " & No & "_" & DocumentNo & "_" & RevisionNo & "?")
FollowHyperlink strPath
Else
MsgBox ("File not found")
End If
End Function
Function FileThere(fileName As String) As Boolean
If (Dir(fileName) = "") Then
FileThere = False
Else
FileThere = True
End If
End Function
Last edited: