Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In an expression...condition Odd or Even? 1

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
I want to format lines in a journal with two different colors for text in records from alternate months. I'm really close. I need to know how to include in an expression (in "Conditional Format") a test for whether the month is odd or even. for example,
Code:
Condition 1:  [TransactionMonth] = Odd   'Jan,Mar,May...
Condition 2:  [TransactionMonth] = Even  'Feb,Apr,Jun...

TransactionMonth is the number that I get with the function: Month(TransactionDate)

Any suggestions?...Or, if there's a better way...Especially if I could format the background of the records...Like the alternate posts in a thread on this site have alternate background colors...how do you do that?

:) Gus Brunston
An old PICKer
padregus@home.com
 
Hi!

To answer the odd/even question, the condtion you want is If [TransactionMonth] Mod 2 = 0 then [TransactionMonth] is even, 1 and it is odd.

As for the other question about an easier way, there was a thread(I think it is in the Microsoft Access: Reports forum) which showed a function where Access looked at the background color and if it wasn't equal to one color, it was changed to that color, and if it was, it was changed to the other color. That way the colors alternated from line to line in the report.

hth
Jeff Bridgham
 
Great!
Thanks.:) Gus Brunston
An old PICKer
padregus@home.com
 
I presume you are getting the month from a date eg Jan 2 2001. If I am correct then this will work. X is the date from which the month will be obtained

If Format(x, "m") Mod 2 = 0 Then

'place the code that here performs the formatting when the month is even

Else
'Place the code here that will perform the formatting when the month is odd.


end if


 
Dear Vic:
Sorry I've not responded to your post earlier--just saw it today. No, the only value I need is the month (any day, any year) in order to format an alternate background color for the continuous records in even and odd numbered months. Did it with jebry's ()Mod 2 function and the Conditional Format capabilities of Access2000. Thanks for you help.
:) Gus Brunston
An old PICKer
padregus@home.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top