Solved

Data Type Mismatch

Posted on 2011-09-20
3
190 Views
Last Modified: 2012-05-12
                 
      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

0
Comment
Question by:mato01
3 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 36568638
How have you declared rst2 and the rest of the variables?

Try this:

Dim rst2 As DAO.Recordset

0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 125 total points
ID: 36568665
IF ... Constraint Number is Text try this

            sql2 = "Delete * From [tbl_GMNA Constraint Report Output] WHERE [Constraint Number]=" & Chr(34) & rst("Constraint Number") & Chr(34)

mx
0
 
LVL 7

Expert Comment

by:BusyMama
ID: 36568749
To help you troubleshoot, put a MsgBox(sql) before the problem row.  That way you can see what the SQL is before the execution.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question