Simple Coding Problem

Capilano

Registered User.
Local time
Today, 22:08
Joined
Feb 19, 2001
Messages
63
Just A simple Coding Problem... How do I get rec.Fields("600")to advance in a simplier way rather than typing in rec.Fields("615") and then rec.Fields("630")? See Sample

Do Until rec.EOF
rec.Edit
If rec.Fields("600") = 15 Then
rec.Fields("600") = 1
Else:
rec.Fields("600") = 0
End If
If rec.Fields("615") = 15 Then
rec.Fields("615") = 1
Else:
rec.Fields("615") = 0
End If
rec.Update
rec.MoveNext
Loop

I need to get all the way up to rec.Fields("2145") by 15's.

Thanks in Advance

Pat
 
I have to assume that you have numeric names for your fields. That is, the field's name is actually 600 or 615. Otherwise question this makes no sense at all.

You can use the field index if the fields are contiguous in the record. (And unless this information is imported directly from another source, there is no reason it could not be.) Heck, one good query and it could be in the right order anyway.

The field index is just the number corresponding to the order in which the field was defined. If you can define these number-named fields in such a way as that they are in the right order and no oddball field stands between adjacent numbered fields, then you only need to know the index.

Just to be sure, you could do this to determine your starting number and ending number (assume if it starts with lo, it is dim'd as a long):

loFNum = rec.Fields("600").Index
loLNum = rec.Fields("2145").Index

For loNum = loFNum to loLNum
... body of loop using rec.Fields(loNum)
Next loNum

Remember, this only works if the number-named fields are exactly adjacent and in the right order for your processing.
 
You could use a for loop with a step of 15

for i = 0 to 2145
rst.edit
if rst.fields(i).value = xxxx then
...
...
...

rst.update
next i
 
Try Int(). Work out your field offset and divide by 15 to get a fields offset using int to ensure the fields offset was incremented by integers
This is pseudocode to give you an idea:
i=600
for i = 600 to 2415 then
j= int((i - 600)/15) + 1
rec.fields = j
next i.
600 to 614 -> 0+1-> 1
615 to 629 -> 1+1-> 2

What are you trying to achieve? There may be a less code intensive way
 

Users who are viewing this thread

Back
Top Bottom