loop variable in field name

G

Guest

I want to assign a value to a field depending on the value of the number in a
for loop. For example, I have fields named [BL 1], [BL 2],...[BL 9] and if i
(the loop counter) = 5, I want to assign the value of a variable dbLength to
[BL 5]. How do I accomplish this? Thanks.
 
G

Guest

you will need to use the Fields collection of your recordset.

Set rst = CurrentDb.OpenRecordset("MyTableName")
With rst
For intCtr = 1 to 5
.Edit
.Fields(format(intCtr, "\[BL 0\]") = SomeValue
.Update
Next intCtr
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top