Link to home
Start Free TrialLog in
Avatar of MarkRJackson
MarkRJacksonFlag for United States of America

asked on

How can I read a DAO recordset record, that has redundunt titles (i.e. [Value_1], [Value_2]) in a loop?

I would like to dynamically assign field names using a counter and loop through the fields of a record in a DAO recordset.  Here is an example:

Dim dbs As Database
Dim rs_RIA As DAO.Recordset
DIm wCTR as Integer
Set dbs = CurrentDb
Set rs_RIA = dbs.OpenRecordset("Select * FROM tbl_RIA", DB_OPEN_DYNASET)
wCtr = 1
rs_RIA.movefirst
Do While not rs_RIA.eof
     Do While wCtr <= 28
          <some variable> = rs_RIA.value_ & wctr
    Loop
     rs_RIA.movenext
Loop

Is there a way to dynamically set the field name and then retrieve the data from the field?
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MarkRJackson

ASKER

Thanks peter57r!  So elegant and so simple.  Much appreciated.