FileExists Method (for Idb)

yippie_ky_yay

Registered User.
Local time
Today, 02:13
Joined
Jul 30, 2002
Messages
338
Hello forum,

I wrote a little procedure that works only when the target db is closed - so, I would like to make sure that it's not in use before I run it.

For some reason though (and I would be interested in the explanation if someone knows why), this won't work - even though it seems to for other types of documents:
If Dir("C:\database\my_db.Idb") = "" Then
MsgBox "Not in use"
Else
MsgBox "It's in use"
End If

But if I look for another type of file, it seems to work fine!? Any ideas on why this doesn't work and/or what I could do to solve my problem?

Thanks in advance,
-Sean
 
Sean:

Have you tried the following:

If IsNull(Dir("C:\database\my_db.Idb") Then
MsgBox "Not in use"
Else
MsgBox "It's in use"
End If

No sure...but it may resolve the problem.
 
Hey jfgambit,

thanks for replying - it didn't work though! Does it work for you?

-Sean
 
Dir("C:\database\my_db.Idb") will return a zero-length string if it doesn't find the file. It won't be equal to Null.

You should use this test:

If Dir("C:\database\my_db.Idb") <>"" Then
 
D-OH!!!!

Thanks for answering everyone! - Looking for ldb instead of idb did it! I won't forget this one any time soon!

Cheers,
-Sean
 

Users who are viewing this thread

Back
Top Bottom