Getting a value based on field name?
Is there an EASY way to do this? What I want to be able to do is get a value from my recordset based on the feild name. At the moment I am using the table index to retrieve the data I need;
Example:
Code:
txtSerialNumber.text = rsSQL.Fields(5).Value
But what I would REALLY like to do instead is get the information based on the field name.. something like:
Code:
txtSerialNumber.text = rsSQL.Fields.SerialNumber.value
but I cant seem to find any documentaion for it or I just dont know where to look. Im kind of a noob when it comes to the database stuff.
thanks
Re: Getting a value based on field name?
Lets say "rs" is the recordset, then you can use
rs("FieldName")
Re: Getting a value based on field name?
Or to be 'proper' about it, like this:
Code:
txtSerialNumber.text = rsSQL.Fields("SerialNumber").value
This works because Fields is a Collection, which you can refer to by position (a number), or by Key (the field name).