rangersedge
Registered User.
- Local time
- Yesterday, 22:52
- Joined
- Jun 13, 2014
- Messages
- 82
I'm trying to use a code to check if a file exists. The code I have already works and gives a MsgBox telling if it exists. It gets the file address through a query that combines multiple fields. This works great when I have the file type entered in the proper field. How do I get this to work if I don't know the file type?
The b variable was meant to find the file without the file type as all my file types are only 3 characters long.
Dim FilePath As String
Dim TestStr As String
Dim a As String
Dim b As String
a = Me.Address
b = LResult = Left(Me.Address, Len(Me.Address) - 3)
FilePath = a
TestStr = ""
On Error Resume Next
TestStr = Dir(FilePath)
On Error GoTo 0
If TestStr = "" Then
MsgBox "File does not exist"
Else
MsgBox "File exist"
End If
The b variable was meant to find the file without the file type as all my file types are only 3 characters long.
Dim FilePath As String
Dim TestStr As String
Dim a As String
Dim b As String
a = Me.Address
b = LResult = Left(Me.Address, Len(Me.Address) - 3)
FilePath = a
TestStr = ""
On Error Resume Next
TestStr = Dir(FilePath)
On Error GoTo 0
If TestStr = "" Then
MsgBox "File does not exist"
Else
MsgBox "File exist"
End If