error 13 type mismatch with Dir() (1 Viewer)

Albilly

Registered User.
Local time
Today, 06:20
Joined
Nov 25, 2015
Messages
31
Hi,
i want to check if a file alerady exist but when I run my code I get the Type mismatch error
I cannot figure this on out, my strname display the proper path and there is a file there, the wildcard is there because the number attached to the file name varies
Code:
strName = "" & DLookup("RepertoireAccess", "LIST_ODBC_STRING", "LABEL = '" & Me.ODBC_AFTER & "'") & "Entrepot*.accde" & ""
                    Debug.Print strName
                    If Dir(strName, vbDirectory) Then
 

Albilly

Registered User.
Local time
Today, 06:20
Joined
Nov 25, 2015
Messages
31
Sorry for the delay, was cought up in an emergency all day.
the line of code that generate the error is
PHP:
If Dir(strName) Then

the variable display the following:
R:\ED\DEV\Entrepot*.accde

I just canmnot figure this one out
Thanks
 

RogerH

Registered User.
Local time
Today, 09:20
Joined
Mar 21, 2016
Messages
34
Sorry for the delay, was cought up in an emergency all day.
the line of code that generate the error is
PHP:
If Dir(strName) Then

the variable display the following:
R:\ED\DEV\Entrepot*.accde

I just canmnot figure this one out
Thanks

The dir() function responds with the name of a file if it finds one, or with an empty string if it does not. So the correct syntax for testing of a file exists is:
If Dir(strName) <> "" Then
 

Users who are viewing this thread

Top Bottom