[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reference Dynamic Field Names

Posted on 2011-10-12
4
Medium Priority
?
271 Views
Last Modified: 2012-05-12
I have a table in which I need to take the data from the field "Name" and copy these values  into a fiield name that is named by the field "Level".

I think I'm close with the code below but I am getting Error 3219 Invalid Operation.  What am I doing wrong?


Set dbs = CurrentDb()
sTable = "tbl_Hierarchy"

    Set rs = dbs.OpenRecordset(sTable)


     rs.MoveFirst
                    
    Do While Not rs.EOF
    
        j = rs!Level + 4
        strName = rs!Name

        
        rs.Edit
        rs(j).Name = strName
        rs.Update
        
        rs.MoveNext
    Loop
   
rs.Close
dbs.Close
Set rs = Nothing

End Sub

Open in new window

0
Comment
Question by:rsaphier
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36956205
try this revision

        rs.Edit
        rs(rs(j).Name) = strName
        rs.Update
0
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 total points
ID: 36956407
If you are trying to copy data from a field in your recordset named "Name" into a field whose name is defined by rs!Level + 4 (this may mean that a different field is filled for each record in your recordset), I believe you need to write it as follows:

        rs.Edit
        rs(j)  = strName
        rs.Update


0
 

Author Closing Comment

by:rsaphier
ID: 36956494
I knew I wasn't too far off the mark and it had to be something simple.  Thanks!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36956577
rsaphier,
did you try the post at http:#a36956205 ?
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

873 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