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
hadorth11Asked:
Who is Participating?
 
MikeP090797Connect With a Mentor Commented:
Check on startup if the file exist, using Dir. If it doesn't, either create an empty database, or ask the use to enter the database path using Open File Dialog
0
 
electrickCommented:
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.

0
 
hadorth11Author Commented:
Hi Mike, Thanks for answering my question but can you show me how to do it. thanks
Lori
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
mcixCommented:
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
0
 
MikeP090797Commented:
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

0
 
hadorth11Author Commented:
Guys, you are wonderful.. I will give your web address to all my friends!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.