Link to home
Start Free TrialLog in
Avatar of mato01
mato01Flag for United States of America

asked on

Data Type Mismatch

                 
      Getting  runtime error on the line below.  Have references set to Microsoft DAO 3.6 Objects Library.
             
            CurrentDb.Execute sql2
           
           
sql2 = "SELECT [tbl_GMNA Constraint Report Output].* FROM [tbl_GMNA Constraint Report Output]"
                  sql2 = sql2 & " WHERE [Constraint Number]='" & rst.Fields("Constraint Number")
                  sql2 = sql2 & "' ORDER BY [tbl_GMNA Constraint Report Output].[Constraint Number] DESC"
                  
                  
                  Set rst2 = CurrentDb.OpenRecordset(sql2, dbOpenDynaset)
                  
                  datMax = rst2.Fields("Date Added")

            
            If rst2.RecordCount > 1 Then
            
            sql2 = "Delete * From [tbl_GMNA Constraint Report Output] WHERE [Constraint Number]=" & rst("Constraint Number")
            sql2 = sql2 & " AND [Date Added] <> #" & datMax & "#"
            
            CurrentDb.Execute sql2
            
            End If
            
            rst2.Close

Open in new window

Avatar of Norie
Norie

How have you declared rst2 and the rest of the variables?

Try this:

Dim rst2 As DAO.Recordset

ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To help you troubleshoot, put a MsgBox(sql) before the problem row.  That way you can see what the SQL is before the execution.