Changing sql databases in Access 2002 .adp

D

David Cowen

The code below seems to switch successfully from one sql
database to another but when I click on File, Connection,
the database has not changed.

Thanks,

David Cowen

Dim cnnDB As ADODB.Connection
Dim ProvStr As String
Dim rs As ADODB.Recordset

' Initialize Connection object
Set cnnDB = New ADODB.Connection
With cnnDB
.Provider = "SQLOLEDB.1"
ProvStr = "Server=Eglsql1; _
Database=Ems_Live;Trusted_Connection=yes;"
.Open (ProvStr)
End With
 
N

Norman Yuan

The code you post does not change connection of the ADP project, which is
CurrentProject.Connection. the code is only open an ADO Connection object
inside the ADP project ( it is useful if you want to get some information
from other database other than the database the ADP project currently
connected to).

To change ADP project's connection, look at CurrentProject.OpenConnection()
and CurrentProject.CloseConnection() methods
 
D

David Cowen

Perfect, thanks!
-----Original Message-----
The code you post does not change connection of the ADP project, which is
CurrentProject.Connection. the code is only open an ADO Connection object
inside the ADP project ( it is useful if you want to get some information
from other database other than the database the ADP project currently
connected to).

To change ADP project's connection, look at CurrentProject.OpenConnection()
and CurrentProject.CloseConnection() methods




.
 

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