Change ADP connection information via code

A

Adam Goossens

Hi all,

I am looking for a way to be able to change the connection information
of an ADP without having to venture into File->Connection.

My reason for doing so is if/when I distribute an ADP I would like to
give my clients the ability to change which SQL server they install the
data tables on. As such I need to be able to change the connection
details of my ADP accordingly.

Ideally, this would occur with as little user interaction as possible,
so that's why File->Connection is not a valid option. I would be popping
up my own dialog during the install process, obtaining connection
information, uploading the data structure and data and then updating the
connection details of the ADP to match.

Does anybody have any ideas or pointers?

Thanks,
-Adam.
 
N

Norman Yuan

You only need a valid ConnectionString to the new SQL Server database and
two lines od code:

''Close existing connection
CurrentProject.CloseConnection

''Open a new connection
CurrentProject.OpenConnection connectionString
 
A

Adam Goossens

Fantasic, thank you.

I should have figured it would be something simple like that.

Regards,
-Adam.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top