473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2858
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
4
by: Christine | last post by:
I am trying to create a data entry form for my database that will enable a user to add a new record or alter an existing record in the table all on one form. So far, the form is set up to display...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: John T Ingato | last post by:
I have a form that shows all the contact data from a query of customers. Each field is bound to a field in the query. If I try to change the "StoreNumber" or any field as a matter of fact, i get...
16
by: RichardP | last post by:
Hi there everyone - I'm new to this forum. I am having an issue when running an application from an instance of Access which has been started through automation (early or late bound, makes no...
7
by: BillE | last post by:
What is the best way to add data using a DataGridView in a multi-tier application (data entry is handled in a data access layer using stored procedures)? Thanks Bill
3
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending...
1
by: Bobby | last post by:
Hi I have a form which I need to call from several different parts of my application. Depending on where it is called from, the Data source will change. The only way I know of to open a form from...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.