Click to See Complete Forum and Search --> : File Location at Design/Run Times


January 12th, 2000, 04:30 PM
I'm relatively new to the VB development world but have extensive C++ development experience. I seem to be having a problem with the location of an Access Database when I run the program. I had the full pathname in the DatabaseName property of a Data Control but when I copied all files to a "Temp" directory to experiment with an idea, errors popped up stating that it was unable to locate <path>\MyFile.mdb at startup. Since I'll not know where the end user will be installing the application files, I attempted to circumvent this by only entering MyFile.mdb without success. I also tried .\MyFile.mdb with the same error(s). Could someone let me know if I'm doing something wrong?

Thanx, Chris.

Lively
January 12th, 2000, 07:11 PM
Chris.

This is a very common issue. Users are very unpredictible. The best way to deal with this situation is to not use properties (design time) to set your database location. Do it in run time and use variables. IE. data1.databasename = G_Datafilename. The info for the variable is stored in a text file(ini) on the users machine and is modified when the user installs the program. This way you know exactly where the database is.

An easier way: Data1.databasename = App.path & "\mydatabase.mdb" The caveat here is that the database MUST always be in the same path as the exe.

Hope this has helped,

Joe B. Lively