473,703 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating odd-numbered and even-numbered years

7 New Member
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.200 6) years.

Thank you
Nov 26 '07 #1
9 2980
joba
7 New Member
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.200 6) years.

Thank you

Joba
Nov 26 '07 #2
atkellyx
16 New Member
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.200 6) 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 Recognized Expert Contributor
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.200 6) 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 New Member
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 New Member
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 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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 New Member
Thank you Mike. It Works perfectly.
Nov 27 '07 #9
MikeTheBike
639 Recognized Expert Contributor
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
8802
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 feedback on how I might do things differently to make it either more consice, readable, or faster. ie... are there better ways to do it in Python? It won't break any records for calculating pi, that wasn't my goal, learning Python was. But it might...
0
2270
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 occured over time. I have no problem in calculating Maximum occurance of events over time. However, I have some NULL values in my Number_of_times_an_event_occured column, due to which I don't see any result when I try to calculate
1
3314
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 forever to open and I'm wondering what it's "calculating" and if that's the bottleneck. Thanks.
1
2377
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 this form. Any employee can have multiple entries in the table (key fields are EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual leave, then take 3 days sick leave in any given month. I have a BeginningBalance of hours that...
0
1784
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 to another application and back between each field that data is entered. I have tried this database on pc's that have office 2000 SP1a and SP3. How do investigate what is causing this calculating issue and how do I resolve it?
20
12597
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
1746
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
2421
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 there's anything more updated. The pages I located on Google turned up broken links. Thanks, - Dave
4
2086
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
4031
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 called purchase_register_details, In sub form i have a unbound textfield called txt_Total_Amount where in i am calculating total amount for different items purchased by giving following code in control source. ContolSource: =Sum() In my main form i...
0
8758
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9121
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4432
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3123
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2450
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.