Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Boise, Idaho, USA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    type mismatch (2002)

    I'm attempting to add a record to a table. My form has unbound fields and when the "Add Record" cmd is clicked I simply want to add the record to the table ( tblMeetingAgendas )

    Here are the first lines of code:

    Dim dbtemp As Database
    Dim rectemp As Recordset

    Set dbtemp = DBEngine(0)(0)
    Set rectemp = dbtemp.OpenRecordset("tblMeetingAgendas", dbOpenDynaset)

    ... when attempting to execute the OpenRecordset line I'm getting a "type mismatch" error. This is a copy of code from another database that works fine. Any assistance in fixing this would be appreciated.

  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 (2002)

    You may have to define the database and recordset objects as DAO. You should also check the references.

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

    Re: type mismatch (2002)

    Pat has probably hit the nail on the head. In particular, declare the recordset as

    Dim rectemp As DAO.Recordset

    and make sure that Microsoft DAO 3.6 Object library is ticked in Tools | References...

    Note: instead of DBEngine(0)(0) you can use CurrentDb.

  4. #4
    Star Lounger
    Join Date
    Apr 2002
    Location
    Boise, Idaho, USA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: type mismatch (2002)

    Thank you, Pat for the information
    and thank you, Hans - for the directions. It works just fine now.
    and thanks for the CurrentDb hint.
    I'm self taught on code and until I learn I generally copy and paste from existing code.
    I appreciate your time.

Posting Permissions

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