I have a form as a main menu with several command buttons. When a button is pressed I want the current database to close and to open another database. I'm not sure of the best way to do this, can anyone help?
This method is using the old DAO reference which is not supported by VB 7 as Microsoft are only going to be using ADO references. I would suggest you code your project to use these instead.
Public Function GetRecordSet()
Dim strConnect As String
Dim rst As ADODB.Recordset
strConnect = "DRIVER=Microsoft Access Driver (*.MDB);DBQ=" & App.Path & "\databse name;"
Set connHelpdesk = New ADODB.Connection
Set rst = New ADODB.Recordset
Set rst = ("SELECT * FROM [table name]"
With rst
.ActiveConnection = strConnect
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Source = strsql
.Open
.MoveLast
.MoveFirst
End With
Set GetRecordSet = rst
End Function
It might look a bit daunting at first, but if you make this a module or class, you can pass the SQL directly into it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.