Check if database exists

rrh

New member
Local time
Today, 14:40
Joined
Nov 13, 2007
Messages
4
So, I'm creating a new database file using CreateDatabase. If the file does not exist, it works, but if it already exists, it gives me an error message and stops my function.

By searching this forum, I found this guy posting how he'll use Kill () to remove the file so he can replace it. But that only works if the file Does exist. How do I make this work regardless of whether the file already exists?

If there is a way I can test whether or not the file exists, that would solve it, I think.
 
one simple way is to use 'On error resume next' ahead of the kill() command.

If the file exists, it will be deleted.

If the file does not exist, it will skip the kill() command without giving an error message.

This may not be the best solution, but it will work.
 
I think this works?

Code:
Function exists()
strDBPath = "full path of database"
strDb = Dir(strDBPath)
If Len(strDb) <> 0 then
    MsgBox "Db exists"
End if
End Function
 
searching the forums you could have found the answer much quicker....
 

Users who are viewing this thread

Back
Top Bottom