Results 1 to 3 of 3
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    Question Data type mismatch in criteria expression - Runtime error '3464'

    I want to delete certain records based on the selected date .


    However, I come across with this is error - Run time error '3464' (Data type mismatch in criteria expression)

    This part is highlighted in yellow. I even used the debug.print to test out if the sql statement is executed properly.
    However, It seems that there's no problem.
    Code:
     DoCmd.RunSQL DelSummarySQL
    Here is my full code
    Code:
    Private Sub cmd_Delete_Click()
    Dim DelSummarySQL As String
    Dim StartRange As Date
        StartRange = CDate(cboStartRange)
        
        DelSummarySQL = "Delete * FROM Summary WHERE Record_Period = '" & StartRange & "' "
        
        Debug.Print DelSummarySQL
        DoCmd.RunSQL DelSummarySQL
        
        
            
        'cmd_Cancel_Click
    End Sub

    Any ideas where went wrong ?
    Thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Parameters for date/time fields need # delimiter, not apostrophe.

    Private Sub cmd_Delete_Click()
    CurrentDb.Execute "Delete FROM Summary WHERE Record_Period = #" & Me.cboStartRange & "#"
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by June7 View Post
    Parameters for date/time fields need # delimiter, not apostrophe.

    Private Sub cmd_Delete_Click()
    CurrentDb.Execute "Delete FROM Summary WHERE Record_Period = #" & Me.cboStartRange & "#"
    End Sub
    That works! Thank you so much

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-16-2014, 09:00 AM
  2. Replies: 3
    Last Post: 07-21-2014, 09:33 AM
  3. Replies: 1
    Last Post: 05-02-2013, 01:29 AM
  4. Error 3464 - Data type mismatch
    By JustLearning in forum Forms
    Replies: 1
    Last Post: 01-18-2013, 08:31 PM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums