Using Mod properly

atrium

Registered User.
Local time
Tomorrow, 00:44
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
 
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.
 
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
 
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

Back
Top Bottom