Results 1 to 2 of 2
  1. #1
    whollycow is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2020

    Error - 3464: Data type mismatch in criteria expression?

    Hi. I have a table. In the table, a field has dates. I make a query with that field. I set up a filter macro that returns results where dates are between Date1 and Date2. My dates are mm/dd/yyyy. In my query, I use CVDate function as an expression for the date field. The reason why is because if I don't do that, the data exported to my excel spreadsheet would not be formatted as date. I have another macro that exports the query to excel. When I run my macro to filter, it gives me error:

    Error - 3464: Data type mismatch in criteria expression

    Note that if I do not use the CVDate function in my query expression, I don't get this error but what gets returned is blank!

    Public Sub cmdSearch_Click()
    On Error GoTo errHandler
     If IsNull (Me.txtDate1) = False Then
       strFilter = strFilter & "[Date] >=#" & Me.txtDate1 & "# AND [Date] <=#" & Me.txtDate2 & "# AND"
     End If
    End If
    If Right(strFilter, 5) = " AND " Then strFilter = Left(strFilter, Len(strFilter) - 5)
        If strFilter <> "" Then
            Me.sfmFindings.Form.Filter = strFilter
            Me.sfmFindings.Form.FilterOn = True
            Me.sfmFindings.Form.Filter = ""
            Me.sfmFindings.Form.FilterOn = False
        End If
    Exit Sub
    If Err.Number = 3075 Then
        MsgBox "Please press Reset button before doing a new Search"
        Resume errExit
        MsgBox "Error - " & Err.Number & ": " & Err.Description, vbCritical, "Fatal Error"
        Resume errExit
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Nevada, USA
    If the field is text as implied by your other thread, you want ' as the delimiter instead of #.
    Paul (wino moderator)
    MS Access MVP 2007-2019

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

Similar Threads

  1. Replies: 3
    Last Post: 12-10-2019, 07:04 PM
  2. Replies: 8
    Last Post: 03-14-2017, 02:36 PM
  3. Replies: 4
    Last Post: 01-18-2017, 09:43 AM
  4. Replies: 3
    Last Post: 01-21-2016, 09:43 PM
  5. Replies: 2
    Last Post: 08-24-2015, 09:14 PM

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 - Senior Forums