Using a variable for a field name in VBA

D

Darren

I have a crosstab query in Access 2003 VBA in which the columns in the
query are variable based on user input from a form. The columns are a
combination of year and quarter (2003_1, 2003_2, ...). The query
displays 5 quarters of data at a time. How can I refer to each of
these columns with a variable???

What I have done thus far does not work:
DataPoint1="2003_1"
DataPoint2="2003_2"
....
blah blah = oRST1![DataPoint1]

When this runs I get "Item not found in the collection"

I have tried setting the DataPoint variables as strings, fields to no
avail.

Would appreciate any help I could get on this.
Thanks.
 
A

Allen Browne

Try:
oRST1(DataPoint1)

Since Fields is the default collection for a recordset, that is interpreted
as:
oRST1.Fields("2003_1")
 
Top