Set a form's recordset

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Set a form's recordset

Post by agibsonsw »

Hello. (Access 2003)
When I double-click a control on a form I want it to show me data from a previous database. I've built a form without a RecordSource and am trying to open it
and set it's recordset property to the one i've opened using ADO. (I can't set its RecordSource, as this would be to a sql statement, not a recordset). Here is a code fragment:
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "c:\Users\Andrew\Documents\Staff Database orig.mdb"
End With
Set rst = New ADODB.Recordset
rst.Open "tblStaff", cnn
DoCmd.OpenForm "frmGetOldData"
With Forms("frmGetOldData")
.Recordset = rst
'.Requery
End With ' How can I push my recordset data into this form? Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Set a form's recordset

Post by agibsonsw »

Please ignore this question - I didn't SET the RecordSet (Set .Recordset = rst). Sorry, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.