loop thru tables field names to update.

skiphooper

Registered User.
Local time
Yesterday, 20:12
Joined
Nov 29, 2000
Messages
76
Hi everyone,
This is part of the code I need to cut down.
' *****************************
Private Sub updatesub1()

int_loop = 1
rstID.AddNew
rstID!stukey = txtStuNum
rstID!SUBCD = int_I
rstID!I001 = Mid(txtsub1, int_loop, 1)
int_loop = int_loop + 1
If int_loop > Val(txtlensub1) Then Exit Sub
rstID!I002 = Mid(txtsub1, int_loop, 1)
int_loop = int_loop + 1
If int_loop > Val(txtlensub1) Then Exit Sub
rstID!I003 = Mid(txtsub1, int_loop, 1)
int_loop = int_loop + 1
If int_loop > Val(txtlensub1) Then Exit Sub
' ect ect ect
' thru
rstID!250
rstID.update
end sub
' ********************************

The code works, but my question is:
How can I loop thru the field names and still
update each field from 1 to 250.

Thanks
Skip



[This message has been edited by skiphooper (edited 02-06-2002).]
 
Don't totally understand the scenario, however, here's a
code-snippet which will hopefully demonstrate a
looping strategy
.

Dim strHold As String, i as integer

intLen = Val(txtLenSub1)


For i = 1 To 250
int_loop = 1
rstID.AddNew
rstID!stukey = txtStuNum
rstID!SUBCD = int_I
Do While int_loop <= intLen
strHold = "I" & Format(int_loop, "000")
rstID(strHold) = Mid(txtSub1, int_loop, 1)
int_loop = int_loop + 1
Loop
rstID.Update
Next i
 
raskew,

worked just fine

Thanks
Skip

P.S.
Is there a way to loop thru the field names
when the names are not sequential.

Skip
 
Take a look at the OrdinalPosition property in the help file. If you're willing to spend the time, you could come up with a process using OrdinalPosition in place of field name.
 

Users who are viewing this thread

Back
Top Bottom