looping through table fields

bjackson

Registered User.
Local time
Today, 16:09
Joined
Jan 3, 2003
Messages
404
I am trying to edit data in a table that has 30 fields.The fields names are W1,W2,- up to W30, and their value would correspond to a control on a form I have declared the controls in an array, so i would really like to use some sort of loop

Is There any way to use a loop to refer to fields to update them rather than
having to use
rst.edit
![W1]=Ctl(1)
![W2]=Ctl(2)
![W3]=Ctl(3)
etc
rst.update

What would the correct syntax be using a for next loop
for i = 1 to 30

rst.edit
!["W" & i]=Ctl(i) - this doesnt work
rst.update

next

thanks in advance
Bjackson :)
 
Ok I worked it out,for anyone else who may be interested,its the same
syntax as a form control

Dim FldName(30) as string
Dim i as long


for i = 1 to 30
FldName(i)="W" & i
rst.edit
fields(FldName(i))=Ctl(i)
rst.update
next
 

Users who are viewing this thread

Back
Top Bottom