set the 'Recordset' property

S

Samuel

Is it possible and how to set the 'Recordset'/'Recordset.Name' property of a
form?

Thank you,
Samuel
 
S

Scott McDaniel

Is it possible and how to set the 'Recordset'/'Recordset.Name' property of a
form?

You simply set it to a valid, open Recordset object:

Dim rst As New ADODB.recordset

rst.Open "SQL", CurrentProject.Connection

Set Me.Recordset = rst

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
D

Douglas J. Steele

David W. Fenton said:
Not true. It works in A2K, which is where this feature was
introduced.

That's why it can only be an ADO recordset that you can assign as a
form's recordset, unfortunately. Or has A2K7 fixed that, by chance?

Thanks for the update, David. I still do most of my work in Access 97, so I
haven't actually played with setting the Recordset that much, but everytime
I have, it has been an ADO recordset (usually a detached one)

Are you saying that the Help file is wrong and you can't assign a DAO
recordset?
 
D

David W. Fenton

Thanks for the update, David. I still do most of my work in Access
97, so I haven't actually played with setting the Recordset that
much, but everytime I have, it has been an ADO recordset (usually
a detached one)

Are you saying that the Help file is wrong and you can't assign a
DAO recordset?

The help file doesn't say you can. Read it very carefully -- it is
quite misleading in the way it is structured.
 
D

David W. Fenton

I don't know about that.

http://msdn2.microsoft.com/en-us/library/aa173231(office.11).aspx
is fairly explicit:

"Returns or sets the ADO Recordset or DAO Recordset object
representing the record source for the specified form, report,
list box control, or combo box control. Read/write."

That's right -- the recordset of the form can be either DAO or ADO,
but you can't *assign* a DAO recordset created elsewhere as the
form's .Recordset.

In other words, the property is read-only for DAO (i.e., you can't
change it once it's created).
 
D

David W. Fenton

That's right -- the recordset of the form can be either DAO or
ADO, but you can't *assign* a DAO recordset created elsewhere as
the form's .Recordset.

In other words, the property is read-only for DAO (i.e., you can't
change it once it's created).

Well, I guess that's not correct after all, according to Michael
Kaplan:

http://trigeminal.com/usenet/usenet022.asp?1033

But I couldn't get a form to accept an ADO recordset for the form's
Recordset property in my own testing.
 
Top