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

Change de default connectionstring at startup

Status
Not open for further replies.

Dalis

Programmer
Dec 26, 2002
2
BE
Hello,

At the open of an access application (ADP).
How can I can change the default connectionstring so that I can access another server and/or SQL DB.
In VBA of course !

Reagrds,

Chris
 
I cant check if it is correct but try currenproject.connection
 
Chrissie,

In this case the DB will be in read only because the property connection is a copy of the original ADO connection.

Chris
 
Here is a function that you can paste into the standard module to check it out. Just change your server name.


Function aokay()
Dim conString As String, conString2 As String

Debug.Print CurrentProject.Connection

conString = "Provider=SQLOLEDB.1;Persist Security Info=False;" & _
"User ID=sa;Initial Catalog=Northwind;Data Source=bigtuna"

conString2 = "Provider=SQLOLEDB.1;Persist Security Info=False;" & _
"User ID=sa;Initial Catalog=Pubs;Data Source=bigtuna"

CurrentProject.CloseConnection
CurrentProject.OpenConnection (conString)
Debug.Print CurrentProject.Connection

CurrentProject.CloseConnection
CurrentProject.OpenConnection (conString2)
Debug.Print CurrentProject.Connection

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top