[AccessD] ADODB Set Me.Recordset = rs - keyset Question

William Thompson william.thompson1 at att.net
Thu Dec 16 09:48:47 CST 2004


Can I change the recordset on-the-fly for a form in an Access project (.adp)
using the method described in the kb
http://support.microsoft.com/default.aspx?scid=kb;en-us;281998  ?  And still
be able to assign the rowset to list and combo boxes?

It's my understanding that SQL Server will only supply one firehose
connection per instance, so I presume that these assigned recordsets, even
if assigned to a listbox, would need to be keyset cursors.

I was wondering if I could re-use connections in a way where, instead of
setting the recordset in the open property of the form, somehow requery the
form with

   Dim cn As ADODB.Connection
   Dim rs As ADODB.Recordset

   'Use the ADO connection that Access uses
   Set cn = CurrentProject.AccessConnection

   'Create an instance of the ADO Recordset class, and
   'set its properties
   Set rs = New ADODB.Recordset
   With rs
      Set .ActiveConnection = cn
      .Source = "SELECT * FROM Customers"
      .LockType = adLockOptimistic
      .CursorType = adOpenKeyset
      .Open
   End With

   'Set the form's Recordset property to the ADO recordset
   Set Me.Recordset = rs

   Set rs = Nothing
   Set cn = Nothing

Could I synchronize updateable subforms using the Mirror method in the ADH?

Any comments, suggestions appreciated,

Bill Thompson
Washington State




More information about the AccessD mailing list