Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2005
    Location
    Hertfordshire, UK
    Posts
    9

    Unanswered: Differences between Recordset and DAO.Recordset?

    Hi,

    I have a form for managing a group of members of a professional association. The recordsource for the form is a query which performs a union of two tables. The following CBF fragment implements part of a a button_Click() subroutine.

    When the code runs, the last line produces an error indicating "Error No.: 13 - Type Mismatch".

    I used the Access XP "Field" Help example as a model. The difference here is that the help example uses "RecordSet" where my code uses "DAO.RecordSet". Is there some difference between the two types of recordset that would explain why my code fails where presumably their example works?

    ===============================

    Dim myForm As Form
    Dim rstForm As DAO.RecordSet
    Dim rstClone As DAO.Recordset
    Dim fldRecordSet As Field

    Set myForm = Forms!frmMembers

    Set rstForm = myForm.RecordSetClone
    rstForm.Bookmark = myForm.Bookmark

    Set rstClone = rstForm.RecordSet.Clone()
    rstClone.Bookmark = rstForm.Bookmark

    Set fldRecordSet = rstClone.Fields(0) ' Error 13 - Type Mismatch

    ===============================

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    The example is probably and ADO example.
    There are differences beween the data libraries
    if you wan tto use the help example try changing your references to ADO
    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Actually - I think the problem is your Field object. Change it to

    Code:
    Dim fldRecordSet As DAO.Field
    If it works I will let you know why...
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Oct 2005
    Location
    Hertfordshire, UK
    Posts
    9
    Yes. Your comments prompted me to change the definition of fldRecordSet
    from:
    Dim fldRecordSet As Field
    to:
    Dim fldRecordSet As DAO.Field

    and the code now works. Should have thought of that before!
    Thanks for your help.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I promised to let you know:

    If you click on

    Tools-> References

    you will almost certainly see a tick against
    Microsoft ActiveX Data Objects 2.x library

    and against
    Microsoft DAO 3.6 Object Library

    and the ActiveX line will be above the DAO line - this indicates precedence.

    Both libraries contain classes for Field and Recordset objects. Without a qualifier (e.g. DAO) Access will get the class for that object from the library with the highest precedence - in this case ADO. So...

    If you are working with DAO AND ADO (not recommended.... but I do <slapped wrist>Poots</slapped wrist>) ALWAYS qualify your objects. If you only use DAO, get rid of the ADO reference but keep qualifying in case you ever migrate.

    HTH

    EDIT - One for the FAQ?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Oct 2005
    Location
    Hertfordshire, UK
    Posts
    9
    Yes, you are quite right. I've taken your advice and removed the ADO reference library. I won't make that mistake again (I hope). Thanks again.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Qualifying is a good habit - ensures Access doesn't get its knickers in a twist but also has other benefits.... Intellisense and efficient execution for two. In fact, I recently read something that advocated qualifying EVERYTHING including, for example:

    Code:
    VBA.Left("MyString", 1)
    Not sure I could be ar**ed though....
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    tsk tsk...

    that would be:

    VBA.Left$("MyString", 1)

    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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