Changing sql databases in Access 2002 .adp

  • Thread starter Thread starter David Cowen
  • Start date Start date
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
 
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
 
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




.
 
Back
Top