flaviooooo
Programmer
Hi,
I have a form where we enter a code. When we press a button, I'd like to have a code that will search for a PDF file with the exact same name as the code, in a specific folder C:\studio\PDF.
For this, I use this code:
Dim rs As Recordset
Dim rstReq As Recordset
Dim strsql As String
Dim strinput As String
Dim varItem As Variant
Dim fs As Object
Dim AppX
DoCmd.SetWarnings False
Set fs = Application.FileSearch
With fs
.Lookin = "Q:\STUDIO\PDF\"
.filename = Me.DRUKCODE & ".pdf"
.SearchSubFolders = True
If .Execute() > 0 Then
strinput = .FoundFiles(1)
AppX = "C:\Program Files\Internet Explorer\iexplore.exe " & strinput
Call Shell(AppX, 1)
Else
MsgBox ("PDF File " & Me.DRUKCODE & ".pdf niet gevonden in Q:\STUDIO\PDF\ !")
End If
End With
DoCmd.SetWarnings True
Unfortunately, there seems to be a problem with this...
When for example I search for code TNC222146, it should look for PDF file 'TNC222146.pdf'. This does not exist, so I should receive an error message that it was not found. The file 'TNC222146sep part B.pdf' on the other hand does exist, and this is returned.
Is there a way to make the filesearch on an exact name??
Thanks in advance
Kind regards,
Fabian
I have a form where we enter a code. When we press a button, I'd like to have a code that will search for a PDF file with the exact same name as the code, in a specific folder C:\studio\PDF.
For this, I use this code:
Dim rs As Recordset
Dim rstReq As Recordset
Dim strsql As String
Dim strinput As String
Dim varItem As Variant
Dim fs As Object
Dim AppX
DoCmd.SetWarnings False
Set fs = Application.FileSearch
With fs
.Lookin = "Q:\STUDIO\PDF\"
.filename = Me.DRUKCODE & ".pdf"
.SearchSubFolders = True
If .Execute() > 0 Then
strinput = .FoundFiles(1)
AppX = "C:\Program Files\Internet Explorer\iexplore.exe " & strinput
Call Shell(AppX, 1)
Else
MsgBox ("PDF File " & Me.DRUKCODE & ".pdf niet gevonden in Q:\STUDIO\PDF\ !")
End If
End With
DoCmd.SetWarnings True
Unfortunately, there seems to be a problem with this...
When for example I search for code TNC222146, it should look for PDF file 'TNC222146.pdf'. This does not exist, so I should receive an error message that it was not found. The file 'TNC222146sep part B.pdf' on the other hand does exist, and this is returned.
Is there a way to make the filesearch on an exact name??
Thanks in advance
Kind regards,
Fabian