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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refering to field names in a recordset 1

Status
Not open for further replies.

lanelouna

Programmer
Dec 19, 2002
71
GB
hello everybody
i have a small problem but it is important to me i hope u can help me
in fact i have to access fieldsi n a recordset, however the name of the fields vary
can i say something like this?or something similar?
For i = 0 To nbr
p = noms(i)
If RS!["Name_" & p ] = 1 Or RS!["Name_" & p] = 0 Then
bla bla bla
knowing that what i wrote is not working, i hope u can help
thanks in advance
Lanelouna
 
Hiya,

Try using the Fields() property of the recordset:
you can specifiy any (valid!) fieldname as string.

example:
Code:
Dim l_sFieldname as string

'Your own bit of code assigning to your recordset RS

'Assign the dynamic fieldname to the string variable
l_sFieldname = "Name " & p

'Refer to this name in your IF statement:
If RS.Fields(l_sFieldname) = 1 Or RS.Fields(l_sFieldname) = 0 Then 
   bla bla bla
End If

HTH

Cheers
Nikki ;-)

 
hello Nikki!
thanks alot for ur helpful reply, it worked like charm!
thanks again
happy new year!
:)
Lanelouna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top