Check file if there

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Markus,

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

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
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
 
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
---------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top