Check file if there

M

Markus

Hallo

I hope some one can help me I need the code to check if a file is there or
note. If not it must give a error message which I want to specify and if the
file is there then nothing continue loading.

Regards

Markus
 
G

Graham R Seach

Markus,

If Dir(strFilename, vbNormal) <> "" Then
'File exists
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
M

Markus

Hi

I have tryd it it does not work maybe i am just to dum

Here is the code i used could you have a look at it what i did wrong it does
not go the ther error message if i change the name of the file

Dim strFilename As String

strFilename = "C:\Windows\"
If Dir(strFilename, vbNormal) <> "AccessC.log" Then
GoTo File_Click
Else
GoTo Error_Click
End If

File_Click:
Exit Sub

Error_Click:
MsgBox "File not there"
Exit Sub
 
G

Graham R Seach

Markus,

strFilename = "C:\Windows\AccessC.log"
If Dir(strFilename, vbNormal) = "AccessC.log" Then
GoTo File_Click
Else
GoTo Error_Click
End If

....or...

strFilename = "C:\Windows\AccessC.log"
If Dir(strFilename, vbNormal) <> "" Then
GoTo File_Click
Else
GoTo Error_Click
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
Top