0

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.

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by BitBlt
0

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.