• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

How to update a recordset with a string variable as the column name

Using Access VBA I have the following code:

        For Each i In squares
            updating = CStr(i)
            currValue = Nz(mrs![0])
            If currValue = "" Then currValue = 0
            mrs.Edit
            mrs!updating = currValue + 1
            mrs.Update
        Next

my recordset is quite large, it has 255 columns.  The i value I have here is the column name I am looking for (a number).  when I do mrs!updating it doesn't seem to like it.  Is there away to do this?  I cant explicitly write out each column name because there are so many but the array has what I need to update and how many to add to each column.

Thanks, hope that makes sense.
0
JeffreyDurham
Asked:
JeffreyDurham
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Maybe this:


        For Each i In squares
            updating = CStr(i)
            currValue = Nz(mrs![0])
            If currValue = "" Then currValue = 0
            mrs.Edit
            mrs(updating) = currValue + 1
            mrs.Update
        Next

mx
0
 
JeffreyDurhamAuthor Commented:
thanks!!
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
You are welcome.

Thank you for using Experts Exchange ...

mx
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now