Query Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sc5502
    New Member
    • Jun 2014
    • 102

    Query Problem

    Background: Front End- MS Access 2010/VBA, Back End- MS SQL Server 2008

    When I run the following code I get this error message: Run-time error '3464': Data type mismatch in criteria expression.

    I put a Debug.Print strSQL statement in the code, copy the output and run it in SQL Studio Mgmt and it works. What am I doing wrong?

    Code:
    strSQL = "Select * FROM dbo_Activity WHERE ID_Projects=  " & CInt(Me.fIDProjects.Value) & "  AND  DateTime='" & Me.fDate2.Value & "';"
    Debug.Print strSQL
    Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)

    Select * FROM dbo_Activity WHERE ID_Projects= 3 AND DateTime='02/20/2015 11:25 AM';
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Date/time values must be surrounded by the pound symbol (#), not single quotes.

    Comment

    Working...