Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2011
    Posts
    3

    Unanswered: Run-time error '13': Type mismatch

    Hi,

    I keep running this access DB and it keeps giving me the Run-time error '13': Type mismatch error at this point:

    Code:
    rtn = RunQuery("SELECT Value FROM DB_Param WHERE Name = 'ISS_Cpty_Summary'", dummyparam)
        ISS_Cpty_Summary = rtn(0, 0)
        
        rtn = RunQuery("SELECT Value FROM DB_Param WHERE Name = 'ISS_ACAI_Summary'", dummyparam)
        ISS_ACAI_Summary = rtn(0, 0)
    I've tried everything... I'm not sure what else to do. HELP!!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What's RunQuery? From which library does it come?
    Have a nice day!

  3. #3
    Join Date
    Aug 2011
    Posts
    3
    hey Sinndho, I'm not sure where it's coming from. I didn't write this code, and I have little to no background in Access. I'm just trying to debug it. I can send you the code if you'd like.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Please do so. However I'm afraid you're using a method (RunQuery) of an object that is not part of the standard libraries of Access. There are other possibilities to get the same result, though. I guess that the purpose of this code is to execute a SQL statement ( two actually) and retrieve a value from the returned data set. I'd like to see the code, or at least a little more of it before going any further. If I'm right, it should not be too hard to translate it into something more standard.

    You can already try this:
    Code:
    '
    ' If rtn is not already declared, declare it.
    '
    Dim rtn As Variant
    '
    ' If the query addresses the current database (not a pass-through query)
    ' this should work with a Recordset.
    '
    Dim rst As DAO.RecordSet
    '
    ' Let's try:
    '
    Set rst = CurrentDb.OpenRecordSet("SELECT Value FROM DB_Param WHERE Name = 'ISS_Cpty_Summary'", dbOpenSnapshot)
    If Not rst.EOF Then 
        rtn = rst.GetRows
        ISS_Cpty_Summary = rtn(0, 0)
    
    Else
        ' No values returned.
    End If
    rst.Close
    Set rst = Nothing
    The same should work with the second query. If this does not work, we'll need to build a function that will emulate the RunQuery function or method from the original code.

    Please could you also check whether there is an object (Table or Query) named DB_Param in the database?
    Have a nice day!

  5. #5
    Join Date
    Aug 2011
    Posts
    3
    Hey Sinndho, I was actually able to debug it. Those two queries were not defined in the DB_Param table, which is actually a static spreadsheet.

    Thanks for your help on this.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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