Filter not working (AND) (1 Viewer)

David Ball

Registered User.
Local time
Today, 09:29
Joined
Aug 9, 2010
Messages
230
Hi,

I have a report that I am trying to filter with VBA code.

After running the code I get the following in the Property Sheet, Data, Filter row:

[Project] IN('KLE323 Piperacks EC Project') AND [Reporting Week Ending] IN(#2/06/2017#)

The report is not working and always stays blank with no records. If I manually modify the string to just [Project] IN('KLE323 Piperacks EC Project') the report opens correctly. If I manually adjust it to just [Reporting Week Ending] IN(#2/06/2017#) the report also opens correctly.

I have double checked that there are records that meet both these criteria.

Is there something wrong with the way I am expressing the "AND"?

Thanks very much

Dave
 

David Ball

Registered User.
Local time
Today, 09:29
Joined
Aug 9, 2010
Messages
230
Actually, when I adjust it to I manually adjust it to just [Reporting Week Ending] IN(#2/06/2017#) the report does not work properly. The report opens with data in it but it is not filtered to just 02/06/2017, it shows all dates.

Looks like there is something wrong with my date format? Any ideas?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 09:59
Joined
Jan 20, 2009
Messages
12,851
Date format should be mm/dd/yyyy
 

David Ball

Registered User.
Local time
Today, 09:29
Joined
Aug 9, 2010
Messages
230
Found the problem. I had to format the date to the ridiculous American date format.

For Each varItem In Me.lsbWEdate.ItemsSelected
strWEdate = strWEdate & ",#" & Format(Me.lsbWEdate.ItemData(varItem) _
, "mm\/dd\/yyyy") & "#"
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:59
Joined
Sep 21, 2011
Messages
14,231
See where that constant for date format starts to come in handy? :)

Found the problem. I had to format the date to the ridiculous American date format.

For Each varItem In Me.lsbWEdate.ItemsSelected
strWEdate = strWEdate & ",#" & Format(Me.lsbWEdate.ItemData(varItem) _
, "mm\/dd\/yyyy") & "#"
 

Users who are viewing this thread

Top Bottom