View Single Post
  #3 (permalink)  
Old October 25th, 2006, 11:45 AM
woodyz woodyz is offline
Friend of Wrox
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

You have several choices in how you can go about this.

The essential task is to dynamically set the DatabaseName property of the datacontrol in code.
Here is what it looks like "hard-coded" to a specific path, which isn't what you want:

Data1.DatabaseName = "e:\shopkeeper\shopkeeper.mdb"

What you need to do is either install the database in some path that you know ahead of time and can hard code into your app, or allow the user to set the path either during the setup process or directly from your application. When a path is entered by the you can store that path in the registry, or in a configuration or ini file of some type that your application is aware of and knows how to access to get the path.

So... lets say you write a function called GetDbPath which returns the path entered by the user. The your code would look something like this:

Data1.DatabaseName = GetDbPath & "\shopkeeper.mdb"

The call to refresh is needed when you are setting properties in code, as this refetches the recrodset.

Woody Z
Reply With Quote