Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Type mismatch error (Access 2000)

    I have a form based on a query that references several tables in a backend database, and in that form's OnCurrent event, I have some code which starts:

    Private Sub Form_Current()
    Dim db As Database
    Dim rs As Recordset
    Dim ...a bunch of variables as variants
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Table1", dbOpenTable)

    When I try to open the form, I get a Type mismatch error at the Set rs... statement.

    Table1 is not one of the linked backend tables, it is in the frontend database, but it's related by a field to the backend tables.

    How do I fix this?

    Thanks for the help.

    Don.

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

    Re: Type mismatch error (Access 2000)

    This may or may not work, but try changing:
    Set rs = db.OpenRecordset("Table1", dbOpenTable)
    to:
    Set rs = db.OpenRecordset("Table1", dbOpenDynaset)

    >>Table1 is not one of the linked backend tables, it is in the frontend database, but it's related by a field to the backend tables.<<
    How is it related?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Type mismatch error (Access 2000)

    There may be confusion over the data model used. Database is only a DAO object, but Recordset can be both ADO and DAO. Try prefixing the types with DAO in the declaration:

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

  4. #4
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Type mismatch error (Access 2000)

    Hans's solution worked. Pat's didn't (before I inserted "DAO" in the Dim statement).

    Thanks much!

    Don.

Posting Permissions

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