Link to home
Start Free TrialLog in
Avatar of hadorth11
hadorth11

asked on

Data Control

Hi,
All my forms have link with the database by data control. the path look like this "C:\WINDOWS\DESKTOP\scan\SOC.mdb"  how about if someone moves the databse from this location, the program will not run! is ther any solution! thanks
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of electrick
electrick

You could write a routine to check for the existance of your
database file.  If it has been moved, then you could have a
routine look for it, then change the databasename property
to the new path.  I built an activeX control to do this.

Avatar of hadorth11

ASKER

Hi Mike, Thanks for answering my question but can you show me how to do it. thanks
Lori
In addition to the proposed solution, you could store the Database Name in an INI/Registry setting.

In the Form_Initialize Event you would read the Setting and verify the existence of the DB.

If the file/path are good, set the datacontrol.databasename = INI setting
To check if a file exist:

If Dir("C:\Windows\Db1.mdb")="" then 'Not exist
 CreateDatabase "C:\Windows\Db1.mdb", dbLangGeneral
 Data1.DatabaseName="C:\Windows=Db1.mdb"
 Data1.Refresh
End If

Guys, you are wonderful.. I will give your web address to all my friends!