Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.

Date Filter not fun...
 
Notifications
Clear all

[Solved] Date Filter not functioning properly

4 Posts
3 Users
1 Reactions
130 Views
Posts: 24
Topic starter
(@arseyguy)
Eminent Member
Joined: 10 months ago

Hi, Please help me with the Date filter. It filters correctly in some dates but sometimes it doesn't and sometimes it shows empty result. Attached is the screenshot showing 0 records and below are the code.

Dim strSearch As String
strSearch = "[DateOfTransaction] Between #" & Me.txtDtFrom & "# and #" & Me.txtDtTo & "#"
Me.Form.Filter = strSearch
Me.Form.FilterOn = True

3 Replies
FStetson
Posts: 60
(@fstetson)
Trusted Member
Joined: 10 months ago

If you could post the entire vba code for your “Search Between” button. It might provide more insight

Reply
Posts: 20
 ursh
Admin
(@ursh)
Member
Joined: 1 year ago

It seems that you are using Date format (dd/mm/yyyy) other than standard. Specify the format for both dates in your code. Like this:

strSearch = "[DateOfTransaction] Between #" & Format(Me.txtDtFrom, "dd/mm/yyyy") & "# and #" & Format(Me.txtDtTo, "dd/mm/yyyy") & "#"

My suggestion is to change your system's default regional format to "English (United States)" if you want to avoid complex date structure and formatting in each vba code. By using this method, your code should work as it is.

Reply
FStetson
Posts: 60
(@fstetson)
Trusted Member
Joined: 10 months ago

Nice catch!  Shamefully, I did not see that.

Reply
Share: