Results 1 to 3 of 3

Thread: Getting a value based on field name?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    8

    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

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Getting a value based on field name?

    Lets say "rs" is the recordset, then you can use

    rs("FieldName")
    thanks
    amrita

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width