Results 1 to 4 of 4

Thread: Fields (2000)

  1. #1
    New Lounger
    Join Date
    Sep 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fields (2000)

    Hello,

    I am sure this is as easy as pie, but I am clueless when it comes to Access. After I declare a recordset and connect it (to say Me.recordset just fro grins and chuckles), how do I correctly access the fields of the new recordset. I try this but keep getting type-mismathces. <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

    MsgBox rstRegist.Fields("FirstName")

    FirstName exists and is a string. Is Fields looking for the field number? How do I tell it to look up something by field name?

    Thank you

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Fields (2000)

    MsgBox rstRegist.Fields("FirstName")

    should probably read

    MsgBox rstRegist("FirstName")
    or
    MsgBox rstRegist!FirstName

    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    New Lounger
    Join Date
    Sep 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fields (2000)

    That did it! Thank you. (There was also a bug a few lines higher that might have been causing this problem)

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Fields (2000)

    There's really no difference between rstRegist.Fields("FirstName") and rstRegist("FirstName"). The Fields collection is the default for a recordset. In fact, if you use a With-End With construction, you *have* to use the .Fields("FirstName") syntax if you want to use a variable for the field name.

    strName = "FirstName"

    With rstRegist
    MsgBox .Fields(strName)
    End With
    Charlotte

Posting Permissions

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