473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Calculating odd-numbered and even-numbered years

7
Hi, I am building a program to calculate vacations for employees. Can anyone show me how to write a VBA code to differentiate even-numbered (Eg 2005) years from odd - numbered(Eg.2006) years.

Thank you
Nov 26 '07 #1
9 2950
joba
7
Hi, I am building a program to calculate vacations for employees. Can anyone show me how to write a VBA code to differentiate even-numbered (Eg 2005) years from odd - numbered(Eg.2006) years.

Thank you

Joba
Nov 26 '07 #2
Hi, I am building a program to calculate vacations for employees. Can anyone show me how to write a VBA code to differentiate even-numbered (Eg 2005) years from odd - numbered(Eg.2006) years.

Thank you
Expand|Select|Wrap|Line Numbers
  1. if [yearToTest] mod 2 = 0 then
  2.    msgbox "even year"
  3. else
  4.    msgbox "odd year"
  5. end if
Cheers AKC
Nov 26 '07 #3
MikeTheBike
639 Expert 512MB
Hi, I am building a program to calculate vacations for employees. Can anyone show me how to write a VBA code to differentiate even-numbered (Eg 2005) years from odd - numbered(Eg.2006) years.

Thank you

Joba
Hi

No sure what you are trying to do, but you could use the Mod operator, ie.

IIF(Year Mod 2 = 0,"Year is Even","Year is Odd")

??

MTB
Nov 26 '07 #4
joba
7
Hi

No sure what you are trying to do, but you could use the Mod operator, ie.

IIF(Year Mod 2 = 0,"Year is Even","Year is Odd")

??

MTB
Thank you for your responds.

What I want to achieve from this program is:
1. When queried for employees to take vacation this year (2007), which is an odd-numbered year, it should select employees who where recruited in odd-numbered years(E.g. 19987 or 1993 or 1801 or 2009)

2. Likewise, next year is an even-numbered year(2008) so the program should select all employees who were recruited in even-numbered years.

I have created a table called members table in my DB with DOE(date of enlistment) as one of is column. The vacation year is every 2 years from DOE for the employees and the query must be focused or based on this value.

Vacation for all employees for the following year is calculated each August. Therefore the vacation forecast for 2008, when querried from the member table , should show all members that where recruited in even-numbered years and thus will have vacation in 2008.

I hope thsi explains what I'm trying to achieve.

Thank you.
Nov 26 '07 #5
joba
7
What I want to achieve from this program is:
1. When queried for employees to take vacation this year (2007), which is an odd-numbered year, it should select employees who where recruited in odd-numbered years(E.g. 19987 or 1993 or 1801 or 2009)

2. Likewise, next year is an even-numbered year(2008) so the program should select all employees who were recruited in even-numbered years.

I have created a table called members table in my DB with DOE(date of enlistment) as one of is column. The vacation year is every 2 years from DOE for the employees and the query must be focused or based on this value.

Vacation for all employees for the following year is calculated each August. Therefore the vacation forecast for 2008, when querried from the member table , should show all members that where recruited in even-numbered years and thus will have vacation in 2008.

I hope thsi explains what I'm trying to achieve.

Thank you.

--------------------------------------------------------------------------------
Nov 27 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
joba

I have merged the three threads on this question into one. It is against site rules to make multiple posts on the same question.

ADMIN
Nov 27 '07 #7
MikeTheBike
639 Expert 512MB
Hi

You could try a WHERE condition in the query
for ODD years use

WHERE IIF(Year([Date of Enlistment]) Mod 2 = 1,1,0) = 1

and for EVEN years

WHERE IIF(Year([Date of Enlistment]) Mod 2 = 1,1,0) = 0

??

MTB
Nov 27 '07 #8
joba
7
Thank you Mike. It Works perfectly.
Nov 27 '07 #9
MikeTheBike
639 Expert 512MB
Thank you Mike. It Works perfectly.
It's always a pleasure to help.

But reflecting on the code (and as I dislike redundant code) it can be simplified (the IIF() function is redundant!) ie

for ODD years use

WHERE Year([Date of Enlistment]) Mod 2 = 1

and for EVEN years

WHERE Year([Date of Enlistment]) Mod 2 = 0

and thanks for letting us know it worked

MTB
Nov 28 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
1
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
0
by: robin9876 | last post by:
In an Access 2000 database on some forms 'Calculating...' is continuously displayed in the status bar window and the text of the control is automatically selected. The only workaround is switching...
20
by: Jean Johnson | last post by:
Hello - I have a start and end time that is written using the following: time.strftime("%b %d %Y %H:%M:%S") How do I calculate the elapsed time? JJ
3
by: laurentc | last post by:
Dear all, I have a simple table, with only the following fields: - Key - MyDate - Price I would like to biuld a Query which uses these fields and which make some
1
by: laredotornado | last post by:
Hi, Can anyone recommend a free script for calculating UPS shipping? I am familiar with the script written in 2000 by Jason Costomiris, but UPS is using an XML interface and I wondered if...
4
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Say I have a class like, class Sample { public decimal first = 10; public decimal second = 20; } I have initialized it
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.