URGENT : Getrows with Fieldnames

Posted on 2007-07-28
Last Modified: 2010-08-05
Hi all

I need to get fieldnames and values into an array so I can cycle through them - I know I can get the recordset values into an array using GetRows

dim arr()
arr = rs.getrows(rs.recordcount)

But that doesnt get the field names.  What I would like to do is get the fieldname, and the fieldvalue, and place it into an array which I can reference in a for ... next statement getting the fieldname and value at the same time

I am not very good with arrays so commented coded answers would be appreciated



Question by:dwe0608
    LVL 1

    Author Comment

    ok - I have worked out a way ... using the following code, where rs is a valid recordset object  

        Dim vFieldNames()
        Dim i
        i = 0
        ReDim vFieldNames(rs.Fields.Count, 1)
        For i = 0 To rs.Fields.Count - 1
            arr(i, 0) = rs.Fields(i).Name
            arr(i, 1) = rs.Fields(i).Value
        Next i

    LVL 48

    Expert Comment

    So, no help required!
    LVL 1

    Author Comment

    DanRollins - I answered my own question - please set to zero points and leave in tact for others to view (I couldnt find an answer on this topic)


    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now