Referring to recordset object in forms code

T

Tanya

This is a general question about the recordset a form
opens. The form is based on a query. It contains several
subforms, none nested. The subforms are all based on
queries. My question is, is it permissable to refer to the
recordset directly using "recordset.method" (movelast,
movenetx, etc.)? Or, should I restrict myself to using
docmd?

I work on my own and am therefore quite reliant on books
and other written documentation. These tend to concentrate
on ADO. The application I'm working on is completely form
driven, so I'm only working with DAO.
 
S

Sandra Daigle

Yes, you can refer directly to the recordset. You can also refer to the
recordsetclone and then set the form's bookmark using the recordsetclone's
bookmark.

The advantage of using the recordsetclone is that record navigation does not
occur on the form itself until (or unless) you set the bookmark of the form.
This allows you to move around in the recordset without any visual evidence.
For example, a common use of the recordsetclone is to find a record matching
some criteria which is usually put into an unbound control:

With me.recordsetclone
.findfirst "Custid=" & me.cboCustid
if not .nomatch then
'set the form's bookmark using the located record
me.bookmark=.bookmark
endif
end with
 
T

Tanya

Thanks! That's exactly what I needed to know.
-----Original Message-----
Yes, you can refer directly to the recordset. You can also refer to the
recordsetclone and then set the form's bookmark using the recordsetclone's
bookmark.

The advantage of using the recordsetclone is that record navigation does not
occur on the form itself until (or unless) you set the bookmark of the form.
This allows you to move around in the recordset without any visual evidence.
For example, a common use of the recordsetclone is to find a record matching
some criteria which is usually put into an unbound control:

With me.recordsetclone
.findfirst "Custid=" & me.cboCustid
if not .nomatch then
'set the form's bookmark using the located record
me.bookmark=.bookmark
endif
end with


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

This is a general question about the recordset a form
opens. The form is based on a query. It contains several
subforms, none nested. The subforms are all based on
queries. My question is, is it permissable to refer to the
recordset directly using "recordset.method" (movelast,
movenetx, etc.)? Or, should I restrict myself to using
docmd?

I work on my own and am therefore quite reliant on books
and other written documentation. These tend to concentrate
on ADO. The application I'm working on is completely form
driven, so I'm only working with DAO.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top