Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Posts
    31

    Unanswered: OpenRecordset error 13

    I'm almost embarrassed to ask this but I'm unable to have the error go away so here it goes.

    I want to add records to a new table using a for next loop.

    I've created a table.

    Dim rst As Recordset

    Set rst = CurrentDb.TableDefs("MissingIQ").OpenRecordset


    'For x = x To 10
    'rst.AddNew
    'rst!serialnumber = x
    'rst!bdsernumber = "Unknown"
    'rst!xemicsserial = "Unknown"
    'rst!CustName = "Option Technologies"
    'rst!Dealername = "Option Technologies"
    'rst!epromrev = "2.13"
    'rst!Assyrev = "1.05"
    'rst!assydate = "10/26/06"
    'rst!shipdate = "10/27/06"
    'rst!manfordernum = "M204390"
    'rst!custordernum = " 81510"
    'rst!model = "IQK1000-9SS-OTI"
    'rst.Update
    'Next x


    rst.Close


    End Function


    It's erroring out on the set statement Runtime error 13 Type mismatch.

    As always, thanks in advance.

    sheila

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    the recordset object exists in both the DAO and the ADO libraries.
    typically ADO is higher up the reference list
    so your recordset is DIMmed as an ADO recordset
    you then use DAO code to Set the recordset ...booom!

    have a go with:
    dim rst as DAO.recordset

    maybe you then get a different error because you don't have a reference set to the DAO library. fix: Alt-F11 & menu Tool/References and set a ref to DAO (in the list under 'M' for Microsoft)

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    PS
    i have not tried your syntax for the recordset open so i don't know if it works your way.

    i would use something like:
    set rst = currentdb.openrecordset("MissingIQ")
    ...or possibly slightly faster:
    set rst = currentdb.openrecordset("SELECT * FROM MissingIQ WHERE 1=2")

    izy



    LATER
    using SQL directly is possibly faster still:
    dim strSQLbase as string
    dim strSQL as string
    strSQLbase = "INSERT INTO MissingIQ(bdsernumber, xcemixserial, custname, etc, etc, serialnumber) VALUES('unknown', 'unknown', 'Option Tech', etc, etc but NOT the serialnumber value or the closing parenthesis
    for X = 1 to 10
    strSQL = strSQLbase & X & ")"
    currentdb.execute strSQL
    next
    Last edited by izyrider; 11-21-07 at 15:37.
    currently using SS 2008R2

  4. #4
    Join Date
    May 2007
    Posts
    31
    I changed my references like you suggested and it worked as expected. Thanks so much for reminding me of that!

    sheila

  5. #5
    Join Date
    Jul 2009
    Posts
    1
    Quote Originally Posted by izyrider
    the recordset object exists in both the DAO and the ADO libraries.
    typically ADO is higher up the reference list
    so your recordset is DIMmed as an ADO recordset
    you then use DAO code to Set the recordset ...booom!

    have a go with:
    dim rst as DAO.recordset

    maybe you then get a different error because you don't have a reference set to the DAO library. fix: Alt-F11 & menu Tool/References and set a ref to DAO (in the list under 'M' for Microsoft)

    izy
    Genius! 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
  •