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?
MarkRJacksonAsked:
Who is Participating?
 
peter57rCommented:
<some variable> = rs_RIA.Fields("value_"  & wctr)
0
 
MarkRJacksonAuthor Commented:
Thanks peter57r!  So elegant and so simple.  Much appreciated.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.