Retrieving field by its index

hchain
04-17-2004, 09:45 AM
I have an ADO recordset.
I can save a Value in a field (named F3 for instance) using:
------------------------------
With Admin.Recordset
!F3 = Value
End With
------------------------------
How can I access field i (i.e., ith field, not knowing its name, something like !Fields(i) = Value) ?

Thanks!
Hervé Chian
Houston, Texas

Shurik12
04-17-2004, 09:47 AM
Hi,


MyValue=Admin.Recordset.Fields(i).Value


Shurik.

hchain
04-17-2004, 10:13 AM
Thanks, but I'm not sure I follow.
This returns the content of field i.
What I want is to place a value in, let's say, the 3rd field of my database.
However, I don not know the name of that field, so I want to access it using an index, not a name.
Basically, I am trying to make a loop to erase columns 3 to 9 of my database, something like:
------------------
'Clear Admin cells
rsAdmin.MoveFirst
For i = 1 To 9
For j = 3 To 9
!Fields(j)=""
Next j
rsAdmin.MoveNext
Next i
-------------------

Thanks!

Shurik12
04-18-2004, 11:14 AM
Yes I seem to have misunderstood you.
First off the recordset should be updatable, if it's the case then

rs.Fields(i).Value= 'bla'
rs.Update


should do.

Regards,
Shurik.

hchain
04-18-2004, 11:53 AM
Thanks Shurik!

My problem was from the exclamation mark.

I would seem that the syntax is:
!FieldName
or
Fields(FieldName)

Have a great week-end :)

Hervé

Shurik12
04-18-2004, 12:01 PM
Good...You too

Shurik.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum