Solved Those Dreaded Dates Again (1 Viewer)

Malcolm17

Member
Local time
Today, 14:48
Joined
Jun 11, 2018
Messages
107
Hey All,

I'm trying to filter a from using a few different combo boxes, one of them is to filter records for a date, I'm using the following code but I keep getting the error "Run Time Error 3709. The search key was not found for any record."

Code:
If Nz(Me.cbxSystemDate, "") <> "" Then
    strWhere = strWhere & "[SystemDate] = '" & Trim(Me.cbxSystemDate) & "' AND "
End If

    If strWhere <> "" Then
        strWhere = Left(strWhere, Len(strWhere) - 5)
        Me.Form.Filter = strWhere
        Me.Form.FilterOn = True
    Else
        Me.Form.Filter = ""
        Me.Form.FilterOn = False
    End If

Can anyone suggest what I need to do to this code to make it work for my date filter please? I'm guessing that its # or something, however I can never quite get my head around dates, which is a nuisance since most of my system is around dates.

Thank you,

Malcolm
 
Yay, I have got it to work with the following:

Code:
If Nz(Me.cbxSystemDate, "") <> "" Then
    strWhere = strWhere & "[SystemDate] = #" & Trim(Me.cbxSystemDate) & "# AND "
End If

:cool:
 

Users who are viewing this thread

Back
Top Bottom