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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable for defining rst field 1

Status
Not open for further replies.

Du2good

Technical User
May 9, 2005
41
US
I’ve a table with 90 different fields named grp00, grp01, grp02, grp03, etc.
The table has one field for the report date (RptDt) and one field for operator ID’s.

Each day I need to update the count of records for each group for each operator ID.

I was hoping to update the table by using a couple of loops to cycle through the recordsets for each group for each operator ID.

This works
rst!Grp00 = GrpCnt

but when I try to use the variable, xx in the rst!Grpxx = GrpCnt to replace the ‘00’ it doesn’t work. Is it possible to make it work? If so please provide the example?
This doesnt work
rst!Grp" & ‘" & xx & "’ = & GrpCnt

I can use an update query, I think, but I haven’t tried it yet. It seems to me it would be a huge query considering the 90 fields to update. Plus I’d hate to edit the query in the future; it’d be a whole lot easier to just add a couple of columns to the table.

Or am I stuck with
rst!Grp00 = GrpCnt00
rst!Grp01 = GrpCnt01
rst!Grp02 = GrpCnt02
rst!Grp03 = GrpCnt03


The purpose of the design is to be able to provide a report that looks like
RptDt OpID Grp00 Grp01 Grp02 Grp03
3/28/08 Tu312 45 15 12 88
3/28/08 Tu792 22 45 78 26
 
I don't thaink you can do it that way with bang (!) notation.

However, something like this should work:

Code:
Dim strFieldName As String

strFieldName = "Grp" & xx
rst(strFieldName) =  GrpCnt


 
Thank you JoeAtWork,

That is exactly what I needed!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top