Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-21
3
Medium Priority
?
314 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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