Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-01
2
Medium Priority
?
258 Views
Last Modified: 2013-11-27
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?
0
Comment
Question by:MarkRJackson
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1000 total points
ID: 22617172
<some variable> = rs_RIA.Fields("value_"  & wctr)
0
 

Author Closing Comment

by:MarkRJackson
ID: 31502070
Thanks peter57r!  So elegant and so simple.  Much appreciated.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question