Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve value of a field 1

Status
Not open for further replies.

YanaD

Programmer
Mar 22, 2001
38
US
i need to retrive a value of a field but looping through a fields like Doc1, Doc2, doc3 and to the doc10. so i did:
for i = 1 to 10
DocValue = rs!doc & i.value
do whatever
next
I need to know if i am right or not?
 
Not quite right.
DocValue = rs("doc" & i.value)

rs!doc & i.value attempts to get the value of the "doc" field, then concatenate the value of the "i" control. In other words, the "!" operation occurs before the "&" operation. Rick Sprague
 
Or you could do it this way:

Dim oField as ADODB.Field
Dim oRs as ADODB.Recordset

'Code...

For Each oField in oRs.Fields
DocValue = oField
'Whatever...
Next

Good Luck
-Mats Hulten

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top