Type Mismatch (Run-Time error '13')

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ragonz355
    New Member
    • Jun 2015
    • 5

    Type Mismatch (Run-Time error '13')

    Recently upgraded a database from 2007 to 2013 and now a section of VBA code does not want to work. What could be the problem. Code is below

    Code:
    Private Sub cmdFindNow_Click()
    
        Dim SelectSQL As String
        Dim stDocName As String
        Dim Response
        Dim dbs As Database
        Dim rstqry As Recordset
        
        If IsNull(Me.txtFindString) Then
        Response = MsgBox("No search criteria entered", 32, "Empty Field Caution")
        Me.txtFindString.SetFocus
        Exit Sub
        End If
        
        CurrentDb.QueryDefs("qryLookupModifiableResults").SQL = QryLookupSQL(txtFindString)
    
    '    DoCmd.SetWarnings False
        
        Set dbs = CurrentDb
        
        stDocName = "qryLookupModifiableresults"
        Set rstqry = dbs.OpenRecordset(stDocName, dbOpenDynaset)
        If rstqry.RecordCount = 0 Then
        Response = MsgBox("No Records Found", 32, "No Criteria Match Caution")
        Me.txtFindString.SetFocus
        Exit Sub
        End If
        
        
        
    
        Dim frmCustomer As Form_Customer
     
        Set frmCustomer = New Form_Customer
     
        frmCustomer.Caption = "Find Results"
        frmCustomer.RecordSource = "qryLookupModifiableresults"
        frmCustomer.Visible = True
     
        CustomerForms.Add frmCustomer
      
    
    '    Dim rs As Object
        
    '   Response = MsgBox("Are you sure you want to delete this record?", vbYesNo, "Delete Caution")
        
    '    If Response = vbYes Then
        
    '         Set rs = Me.Recordset
    '         rs.Delete
    '         rs.MoveNext
    '         If rs.EOF Then rs.MovePrevious
        
    '         Me.Refresh
             
    '    End If
    End Sub
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    My guess is the Query qryLookupModifi ableresults is missing or there is an error being thrown in QryLookupSQL() (which could amount to the same thing), but it would be a lot easier to guess if you could point out which line the error is happening on.

    Comment

    • Ragonz355
      New Member
      • Jun 2015
      • 5

      #3
      Code runs perfectly in a non-upgraded database.
      Error is apparently on this line

      Code:
      Set rstqry = dbs.OpenRecordset(stDocName, dbOpenDynaset)

      Comment

      • jforbes
        Recognized Expert Top Contributor
        • Aug 2014
        • 1107

        #4
        Does the Query "qryLookupModif iableresults" exists? If it exists, can you successfully open it?

        Line 15 updates the QueryDef for the Query, It's quite possible that it is putting something in the QueryDef that Access can't understand.

        Comment

        • madankarmukta
          Contributor
          • Apr 2008
          • 308

          #5
          I guess the problem exists with not having the read permission to the newly upgraded DB. If , could post the exact error message you are getting, may guide us to help you.

          Is it working for the other user ?

          Comment

          Working...