468,249 Members | 1,504 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

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

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
2 2531
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
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.

Similar topics

3 posts views Thread by John T Ingato | last post: by
7 posts views Thread by BillE | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.