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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ms access path specification in basic

Status
Not open for further replies.

stallion

Programmer
Feb 22, 2000
14
GB
hi
how would i overcome the problem of the database path when transferring the project and database file from one computer to another. My first idea was to use the 3 file and drive boxes so when the program started the user could specify where the file was on their computer, how would i do this though so that when the database file is highlighted the databar.databasename control changes also

sorry about the clarity
thanks nick
 
Here’s how I approached the very same problem when using the intrinsic data control to connect to an Access database:

1) leave the DatabaseName property of the data control empty in design mode – this ensures that the recordset cannot be built using a bad path during initialization.

2) place the following code in the host form’s initialize event:
Data1.DatabaseName = App.Path & "FileName.mdb"
Data1.Refresh

This will only work if the database file is in the same directory as your program’s executable. If the database file will be kept in a subdirectory to that of the executable, just include the path along with the file name as in: Data1.DatabaseName = App.Path & “Data\FileName.mdb”

I realize that this was not the direction that you intended to go. Nonetheless, it is a viable alternative.

Hope this helps.
 
hi
thanks for your reponse
if i leave the database name blank it wont allow me to attatch any of the text boxes i have to the database fields because the database is not specified. what am i doing wrong
thanks for your help
nick
 
I gather that you have various controls bound to the data control. If so, you are correct in saying that you need to specify a database name and record source to bind these controls. The trick is to set these two properties, bind your controls (i.e. textboxes), AND THEN clear the DatabaseName property of the intrinsic data control at design time. This will enable you to see the fields that you want to attach your textboxes to. You just have to clear the DatabaseName property sometime before you compile and deploy the app. However, it's probably best to do this when you're finished binding all the controls so that you're sure that this property is being set correctly using the code listed above.

I hope this clarifies things for you.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top