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!

Dynamically referencing fields in a recordset

Status
Not open for further replies.

WatDisDo

Programmer
Jul 7, 2001
3
GB
Hi Everyone

I am attemting to access the fields in a recordset using a field name derived dynamically, i.e. along the lines of :

dim somevar as string
.
.
.
rs.fields(somevar) or rs!somevar

This obviously doesn't work, as the methods seem to expect literal values rather than dynamic for field names. Has anyone any ideas, or am I missing something here.

Thanks in advance X-)

Malcolm.



 
I do believe you are on the right track. You can reference fields by name, which you can create dynamically and set in a variable. You just have to say

rs.Fields(somevar).Value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top