Hi experts out there, I'm using ms access to store a date value in (dd/mm/yyyy) format. This field too stores text value something like e.g: N/A. When user selects a date (dd/MM/yyyy) via dtpicker, i want the datagrid to be filtered by that date if it found in that date field else do nothing. But, when i run my program, it does nothing. My code:

Private Sub DTPicker1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Dim rs2 As New ADODB.Recordset
Dim SQL As String
SQL = "Select * from tblECN where D_BOM=" & DTPicker1.Value & ""
With rs2
.Open SQL, DB, adOpenStatic, adLockReadOnly

Do While Not .EOF
    If IsDate(!D_BOM) = False Then
    Else
    datPrimaryRS.Recordset.Filter = "D_BOM='" & DTPicker1.Value & "'"
    End If
    .MoveNext
Loop
End With
Set rs2 = Nothing
End If
End Sub

Please help me friends.

If I recall correctly, any time you specify a date literal in MSAccess SQL, you have to use # as your delimiter rather than quotes (e.g. #4/11/2011#) otherwise it gets treated as just another string...then you run afoul of all the nasty date formatting issues such as 4/11/2011 <> 04/11/2011 and the like. Hope this helps!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.