[AccessD] Iterate through similarlnamed columns in a recordset

Jim Lawrence accessd at shaw.ca
Wed Jun 15 12:30:48 CDT 2005


Hi Arthur:

 

Here is a piece of code that loops through a couple tables and all fields.

 

With rs1

 .MoveLast

 .MoveFirst

 Do While .EOF = False

  rs2.AddNew

  For i = 0 To .Fields.Count - 1

   rs2.Fields(i).Value = .Fields(i).Value

  Next

  rs2.Update

  .MoveNext

 Loop

End with

 

HTH

Jim

 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Wednesday, June 15, 2005 4:08 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Iterate through similarlnamed columns in a recordset

 

You have a table like this (let's not bring up normalisation)...

 

PK autonumber

Size1 long

Height1 long

Weight1 long

 

(The last three are repeated 3 times, so their last digits are 2, 3 and 4.)

 

Assume the required vars are declared and filled. rs = New

ADODB.RecordSet. etc.

I want to write a loop something like this:

 

For i = 1 to 4

    debug.print rs("Size"&i)

    etc.

Next

 

But I can't seem to get it right. I tried using eval() and various other

approaches. Ideas?

 

Arthur

 

-- 

AccessD mailing list

AccessD at databaseadvisors.com

http://databaseadvisors.com/mailman/listinfo/accessd

Website: http://www.databaseadvisors.com




More information about the AccessD mailing list