Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you pull access field names into an array?

Status
Not open for further replies.

dmodele

Technical User
Jul 30, 2002
19
0
0
US
Does anyone know how to pull all the field names of an access query into an array so that you could loop (for each) through them and do some action with every value that they contain for a certain record?

 
Take a look at the Name property of a Field in a Recordset object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
They are already in an "array" (the Fields collection).
so after using the OpenDatabase Method :-
Code:
    '- HEADINGS TO SHEET
    For F = 1 To NewProjectList.Fields.Count
        Set MyField = NewProjectList.Fields(F)
        ActiveSheet.Cells(1, F).Value = MyField.Name
    Next

Regards
BrianB
Use CupOfCoffee to speed up all windows applications
================================
 
depends how you are accessing the query I guess - and what app you are using....????

As an example you can use something like this which should be pretty generic:
Code:
OPTION BASE 1
Set rst = dbs.OpenRecordset(sQuery) 'set query results = recordset objects
For iCol = 1 To [b]rst.Fields.Count[/b]
myArray(iCol) = rst.fields(iCol).name
next iCol

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top