Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Certys@gmail.com
Guest
 
Posts: n/a
#1: Mar 16 '07
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.


Allen Browne
Guest
 
Posts: n/a
#2: Mar 16 '07

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


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.

<Certys@gmail.comwrote in message
news:1174017571.927902.164480@l77g2000hsb.googlegr oups.com...
Quote:
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.
certys
Guest
 
Posts: n/a
#3: Mar 17 '07

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


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:
Quote:
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
Closed Thread