ebbsamsung
Registered User.
- Local time
- Yesterday, 18:41
- Joined
- May 22, 2014
- Messages
- 19
Good day Experts,
Here i am again for a revision of my simple db based of what my boss said. Is it possible to modify this piece of code with the following modification?
Sample:
I have two criteria:
If Not qualify to this criteria
filetosearch = Me.No & "_" & Me.DocumentNo & "_" & Me.RevisionNo & ".pdf"
Then this criteria will be used
filetosearch = Me.No & "_" & Me.DocumentNo & ".pdf"
Then find the pdf file
How can i modify this code using a conditional statement?
I dont know where to put exactly the conditional statement.
I can understand only basic or simple vba a novice like me.
Could somebody please help me for this.
Here i am again for a revision of my simple db based of what my boss said. Is it possible to modify this piece of code with the following modification?
Sample:
I have two criteria:
If Not qualify to this criteria
filetosearch = Me.No & "_" & Me.DocumentNo & "_" & Me.RevisionNo & ".pdf"
Then this criteria will be used
filetosearch = Me.No & "_" & Me.DocumentNo & ".pdf"
Then find the pdf file
How can i modify this code using a conditional statement?
I dont know where to put exactly the conditional statement.
I can understand only basic or simple vba a novice like me.
Could somebody please help me for this.
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"
'you may need to add & ".pdf" onto the filetosearch line if the combobox doesn't have .pdf in it
direc = Nz(DLookup("PDFsFolder", "tblPDF", "PdfId = 1"), "")
RecursiveDir colFiles, direc, filetosearch, True
Dim vFile As Variant
For Each vFile In colFiles
OpenAnyFile (vFile)
Next vFile
'keep as false for a few tests so it only looks in your current folder
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