By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

Using recordsetclone when only allowing new records to be added (Form Property Data Entry = yes)

P: n/a
Hello,

I have a form where I only allow new records to be added. I enable
this by setting the form property "Data Entry" to Yes.

I want to access other records in the same table- to autofill the new
record with a user select previous record.

Dim rs As Recordset
Set rs = Me.RecordsetClone
rs.MoveLast

MsgBox rs.RecordCount 'returns error when Data Entry =
Yes

When only allowing new records, this code returns "Run-time error
'3201', No current record." It works fine if the form isn't only
allowing new records.

Thank you in advance for reading this and providing assistance.

Mar 16 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You cannot use RecordsetClone for records that are not in the form. As the
name suggests, the clone set contains only the same records as in the form.

You will need to use another approach to retrieving other data from the
table. DLookup() might be the simplest:
http://allenbrowne.com/casu-07.html

OpenRecordset() will be more efficient if you are retrieving multiple
values, but requires some understanding of how to code it. Here's a basic
example:
http://allenbrowne.com/func-DAO.html...cordsetExample

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ce****@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Hello,

I have a form where I only allow new records to be added. I enable
this by setting the form property "Data Entry" to Yes.

I want to access other records in the same table- to autofill the new
record with a user select previous record.

Dim rs As Recordset
Set rs = Me.RecordsetClone
rs.MoveLast

MsgBox rs.RecordCount 'returns error when Data Entry =
Yes

When only allowing new records, this code returns "Run-time error
'3201', No current record." It works fine if the form isn't only
allowing new records.

Thank you in advance for reading this and providing assistance.
Mar 16 '07 #2

P: n/a
Thank you Allen. I have successfully used OpenRecordset() and it works
wonderfully.

Thank you.
On Mar 15, 11:51 pm, "Allen Browne" <AllenBro...@SeeSig.Invalid>
wrote:
You cannot use RecordsetClone for records that are not in the form. As the
name suggests, the clone set contains only the same records as in the form.

You will need to use another approach to retrieving other data from the
table. DLookup() might be the simplest:
http://allenbrowne.com/casu-07.html

OpenRecordset() will be more efficient if you are retrieving multiple
values, but requires some understanding of how to code it. Here's a basic
example:
http://allenbrowne.com/func-DAO.html...cordsetExample
Mar 17 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.