Solved

Data Type Mismatch

Posted on 2011-09-20
3
191 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 - Microsoft MVP, Access and Data Platform) 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 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