473,405 Members | 2,272 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,405 software developers and data experts.

Recordset CopyRecord

Found some stuff on Google about this, but it was older and only applied
to form code when a table was being displayed.

Anyway, I am adding records to a recordset where the values I am
inserting are based on the values in the current record. The easiest
way to do this is to copy the current record, do an insert, and perform
the adjustments on the newly inserted record.

I am wondering if there is a more elegant way to do this than:

strFld1 = rst!Fld1
strFld2 = rst!Fld2
... etc ...

rst.AddNew
rst!Fld1 = strFld1
rst!Fld2 = strFld2
... etc ...

// Perform adjustments

.... because there are a lot of fields in the record.
Nov 13 '05 #1
2 1498
You could loop through the fields and refer to them by number:
For i = 0 to rst.Fields.Count - 1
Debug.Print rst.Fields(0)
Next

Depending on the context, you could copy from one recordset directly to
another (or to a new record in the clone set), copy them to an array, or use
the loop to build up the SQL string for an Append query statement.

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

"John Baker" <ba*****@ix.netcom.com> wrote in message
news:V4*******************@fe2.columbus.rr.com...
Found some stuff on Google about this, but it was older and only applied
to form code when a table was being displayed.

Anyway, I am adding records to a recordset where the values I am inserting
are based on the values in the current record. The easiest way to do this
is to copy the current record, do an insert, and perform the adjustments
on the newly inserted record.

I am wondering if there is a more elegant way to do this than:

strFld1 = rst!Fld1
strFld2 = rst!Fld2
... etc ...

rst.AddNew
rst!Fld1 = strFld1
rst!Fld2 = strFld2
... etc ...

// Perform adjustments

... because there are a lot of fields in the record.

Nov 13 '05 #2
Allen Browne wrote:
You could loop through the fields and refer to them by number:
For i = 0 to rst.Fields.Count - 1
Debug.Print rst.Fields(0)
Next


Aye, still have to store them somewhere so they can be refererred to
after that .AddNew. An array would do the trick I guess.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: gary artim | last post by:
Hi All, I have a problem using DBIx::RecordSet. I get correct results but continue to get these messages on stderr. I looked at Compat.pm and it seems to be pointing out a problem with my call...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
19
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
0
by: CFW | last post by:
I thought this was going to be easy but I'm missing something . . . I need to open an ADODB recordset using the recordset source for a list box on my for. When my form opens, the list box ADODB...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.