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

link to another database

Status
Not open for further replies.

thoms314159

Technical User
Apr 8, 2003
13
CA
Can anybody tell me there is a way to open another distinct database from within a currently openned database. Say from a command button? Thanks.
 
Do you ever use currentdb in opening recordsets? Substitute the rigorous name of the new db as you would use currentdb.

Dim db1 as DAO.database

set db1 = .... check with help to get the protocol for this.

email me if you have a problem and I will look up some of my old stuff and send you an example.

rollie@bwsys.net
 
Here are a couple of functions that I call from a button click. The functions are in a standard module.

Option Explicit
Public pubAppAccess As Access.Application, pubOldAccess As Access.Application
Public pubFilePath As String
Public pubStartWindow As String, pubObj As Object
Public pubCNN As ADODB.Connection
Public pubCmd As New ADODB.Command
Public pubRS As New ADODB.Recordset


Function ConnectToOnLineDB()

' Open a connection to the Online Database
Set pubCNN = New ADODB.Connection
pubCNN.ConnectionString = "driver={SQL Server};" & _
"server=Guapote;uid=sa;pwd=;database=Pubs"
pubCNN.ConnectionTimeout = 30
pubCNN.Open

Debug.Print "pubCNN connection = "; pubCNN

End Function

Function ConnectToOffLineDB()

' Open a connection to the Offline Database
Set pubCNN = New ADODB.Connection
pubCNN.ConnectionString = "driver={SQL Server};" & _
"server=localhost;uid=sa;pwd=;database=Pubs"
pubCNN.ConnectionTimeout = 30
pubCNN.Open

Debug.Print "pubCNN connection = "; pubCNN

End Function

Function CloseDatabase()

pubCNN.Close
Set pubCNN = Nothing

End Function

Function CheckDatabase()

Dim SqlString As String, CNT As Integer
Dim RSMT As ADODB.Recordset
' Open a connection without using a Data Source Name (DSN).
Set pubCNN = New ADODB.Connection
pubCNN.ConnectionString = "driver={SQL Server};" & _
"server=Guapote;uid=sa;pwd=;database=Pubs"
pubCNN.ConnectionTimeout = 30
pubCNN.Open

Debug.Print "pubCNN connection = "; pubCNN

End Function

Function OpenAccessProjectLocal()

' Close the open database.
Set pubOldAccess = Access.Application
Debug.Print " access app = "; pubOldAccess.CurrentProject.Name

' Open Access project.
pubFilePath = "C:\compudyne\alaris\projects\localpubs.adp"
Set pubAppAccess = New Access.Application
pubAppAccess.OpenAccessProject pubFilePath

Debug.Print " file path = "; pubFilePath
Debug.Print " access app = "; pubAppAccess.CurrentProject.Name

pubAppAccess.Application.RefreshDatabaseWindow
pubAppAccess.Application.Visible = True
Debug.Print " Old database "; pubOldAccess.CurrentProject.Name

End Function

Function OpenAccessProjectServer()

' Close the open database.
Set pubOldAccess = Access.Application
Debug.Print " access app = "; pubOldAccess.CurrentProject.Name

' Open Access project.
pubFilePath = "C:\compudyne\alaris\projects\remotepubs.adp"
Set pubAppAccess = New Access.Application
pubAppAccess.OpenAccessProject pubFilePath

Debug.Print " file path = "; pubFilePath
Debug.Print " access app = "; pubAppAccess.CurrentProject.Name

pubAppAccess.Application.RefreshDatabaseWindow
pubAppAccess.Application.Visible = True
Debug.Print " Old database "; pubOldAccess.CurrentProject.Name

End Function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top