Solved

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

Posted on 2011-03-21
3
299 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 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

737 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