Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if the file exists

Status
Not open for further replies.

krzysrb

Technical User
Jun 23, 2003
30
CA
hey guys

i have a problem with JET engine in this li'l program i am trying to write. I have hardcoded the data control references to my database, but this doesnt get me far. the moment i make a change in the DB placement, it gives me an error. is there any way to quickly check if the DB is where i think it is? so far i have been using the syntax

mdbPath = app.path & "\db1.mdb"

but as soon as i move the DB, of course, it shoots out an error. all i wanna do is get the right path, and this doesnt work out well.

thanks a lot all

vlada
 
Maybe you could store the path in the registry, then when you move the database just update the registry. Then use something like this

MdbPath = GetSetting("Myappname", "Database", "MdbPath", app.path) & "\db1.mdb

If Dir(mdbpath) = "" Then
MsgBox "file is not there"
....
End If



 
You could place this in the Sub Main which gets executed before any other objects are loaded:

If Dir(App.Path & "\MyDB.Mdb",vbNormal)=vbNullString Then
MsgBox "myDB.MDB was not found in the Application Folder"
End
End If



 
Thanks CCLINT, it works like a charm. now, being able to se if the file is there where i wanted to be, is there a way to let the user select (in case that the file has been moved) the correct place where the DB resides? Would i be best off by using the common dialog? and can i save the exact path by doing that, so i can change the refernces in my program to it?

thanks a lot guys
vlada
 
>Thanks CCLINT,

And to SonOfEmidec1100
We just happened to post at the same time...


>using the common dialog
Yes


>and can i save the exact path by doing that
Yes
Use the getSettings that SonOfEmidec1100 pointed you to.
 
CCLINT and SonOfEmidec1100, you guys are great help. fixed it all using the dialog and now, it not only works, but it purrs while doing it.

once again, thanks

vlada
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top