?
Solved

Disconnected recordset

Posted on 1999-10-26
2
Medium Priority
?
164 Views
Last Modified: 2010-05-02
This should be very simple but I just can't seem to get my head around this.  I need a way to open a recordset from the client side and close the connection to the database.  I then want to be able to use the recordset to bind to a datasource for a report. I'll start this out at 30 points and increase depending upon the comments given.
0
Comment
Question by:tkuppinen
2 Comments
 
LVL 4

Accepted Solution

by:
Juilette earned 120 total points
ID: 2159339
'open database and set database and recordset

'to close it use close.cDBName
'close recordset...close.rs

Public Sub OpenDB()

              Dim AppPath$
           
        If Right(App.Path, 1) <> "\" Then _
              AppPath = App.Path & "\" _
        Else AppPath = App.Path
       
              cDBName = AppPath & "Art.mdb"
       
              cTblName = "Gallery"

              Data1.DatabaseName = cDBName
              Data1.RecordSource = cTblName
         
              Data1.Refresh

          End Sub

      Private Sub Form_Load()
      '
              Call OpenDB
      '
              Set db = Workspaces(0).OpenDatabase(cDBName)
              Set rs = db.OpenRecordset(cTblName)

      End Sub

'doesn't answer all but might be of help
0
 
LVL 1

Author Comment

by:tkuppinen
ID: 2159378
Actually, I was able to find the answer I was looking for by looking at another question.  I'll post the answer I came up with and give juliette the pointsd just to add this to the archive.n  This is part of a test system and to implement this in an n-tier application there will be modifications but I think the general idea is here.

Dim rsTest As ADOR.Recordset, cmdTest As ADODB.Command
Set cmdTest = New ADODB.Command
Set rsTest = New ADOR.Recordset
cn.Open ("aps_test")
cmdTest.ActiveConnection = cn
cmdTest.CommandText = "select f_name from employees"
cmdTest.CommandType = adCmdText
rsTest.CursorLocation = adUseClient
rsTest.LockType = adLockOptimistic

rsTest.Open cmdTest
Set rsTest.ActiveConnection = Nothing

cn.Close
rsTest.MoveFirst
MsgBox rsTest("f_name")
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question