Using Mod properly (1 Viewer)

atrium

Registered User.
Local time
Today, 19:34
Joined
May 13, 2014
Messages
348
I have a need to determine if a field is odd or even
Code:
Me.Filter = "(UserId = " & Me.UserIdFld & " OR ActionDueDate <= (Date() - 21)) & " AND ((Me.MatterShortNo) MOD 2 = 1)"     ' and Matter number is Odd

Obviously my syntax is wrong but I can't see it

Any help would be appreciated
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:34
Joined
Jan 20, 2009
Messages
12,853
It is hard to know exactly what you are trying to do.
The first part has incorrect quotes. This is what you want there.

Code:
Me.Filter = "(UserId = " & Me.UserIdFld & " OR ActionDueDate <= (Date() - 21))"


Code:
" AND ((Me.MatterShortNo) MOD 2 = 1)"

This section will concatenate that whole expression literally to the filter. Me doesn't register inside the form so it can't be right.

If this expression is evaluated in the VBA then it will return True or False. You would not put that in a filter but test it before building the filter.

Depends what you are trying to do.

Use a variable to get the filter string and view it to see if it is what you expect.
 

sonic8

AWF VIP
Local time
Today, 11:34
Joined
Oct 27, 2015
Messages
998
Obviously my syntax is wrong but I can't see it
Galaxiom pointed out the problem with the syntax. Beyond that the logic is wrong.


anyEvenNumber Mod 2 = 0
 

isladogs

MVP / VIP
Local time
Today, 10:34
Joined
Jan 14, 2017
Messages
18,247
Galaxiom pointed out the problem with the syntax. Beyond that the logic is wrong.


anyEvenNumber Mod 2 = 0

True ... for even numbers ... but in post 1, it specifies odd numbers
 

Users who are viewing this thread

Top Bottom