Results 1 to 3 of 3

Thread: Access and Fields of Recordsets using DAO3.6 [Resolved]

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    62

    Resolved Access and Fields of Recordsets using DAO3.6 [Resolved]

    Hi,

    I'm having a problem retrieving fields from a recordset when using SQL in access. My code is this

    Code:
    varSQL = "SELECT * FROM tblemployees"
    Set db = CurrentDb
      Set rs = db.OpenRecordset(varSQL, dbOpenDynaset, dbReadOnly)
    rs.MoveFirst
    Do While Not rs.EOF
    MsgBox rs.Fields("lastcontactdate")
    If rs.Fields("lastcontactdate") < varCompareDate Then
    varcount = varcount + 1
    rs.MoveNext
    Else
    rs.MoveNext
    End If
    Loop
    the rs.fields("lastcontactdate") line always seems to bring up an error "Item not found in this collection". Any thoughts on a speedy resolution?
    Last edited by Zukovsky; May 26th, 2005 at 07:56 AM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Access and Fields of Recordsets using DAO3.6

    Make sure you have a field called lastcontactdate in tblemployees, and that it's all spelled correctly.
    Then check the recordset. One way to do this is to put a Stop statement after the line Set rs = db.OpenRecordset..., then check the Locals window. You should see an entry called rs. Expand the plus sign, then the Fields plus sign. Your fields are called Item 1, Item 2, etc. Expand them until you find one with the Name value of lastcontactdate. If it's not there, it's not in your recordset.
    Tengo mas preguntas que contestas

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2002
    Posts
    62

    Resolved Re: Access and Fields of Recordsets using DAO3.6

    Ah, you're right. Simple case of mis-spelling.


    Thanks

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