Solved

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

Posted on 2011-03-21
3
277 Views
Last Modified: 2012-06-27
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
Comment
Question by:JeffreyDurham
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 35186768
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
 

Author Closing Comment

by:JeffreyDurham
ID: 35186778
thanks!!
0
 
LVL 75
ID: 35186789
You are welcome.

Thank you for using Experts Exchange ...

mx
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

816 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

13 Experts available now in Live!

Get 1:1 Help Now