Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Location
    N.Ireland
    Posts
    10

    Cool Unanswered: Identifying Odd and Even Values

    Hi all

    I am having a problem which I hope someone can help with.

    Our company has a Timeand Attendance system which records employee clockings. I am using Access 2000 to produce a "Roll Call" report which will show employees as "In" or "Out". I am working on the principle that an uneven number of clockings means they are "In" and an even number of clockings means they are "Out". I have found a function which is used for printing Odd or Even reports called 'Mod' but I don't know how it works.

    Basically I need a function or macro that will evaluate the number of clockings on the system for an employee and decide that if the number is even then they are "Out", but if the number is uneven then they are "In"

    Hope this all makes sense, and hope some can help.

    Cheers and thanks in anticipation.

    Regards

    Tim

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try
    if (NoClockings mod 2)=1 then
    'insert code for still logged in
    else
    'insert code for logged out
    endif

    OR

    CurrentState="Clocked " & iif((NoClockings mod 2)=0,"Out","In")

    Not sure you have got hte business rule right though, what happens if you get a clock in / out that is out of sequence, ie forgot to clock in yesterday thereofe have to clock outs in sucession.

  3. #3
    Join Date
    Oct 2004
    Location
    N.Ireland
    Posts
    10

    Smile Thanks

    Cheers

    Many thanks I will have a go with those options.

    We have an anomolly check in place which should catch any missed clockings hopefully.

    Cheers for the help.

  4. #4
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    Just a very quick maths lesson here, Mod is the remainder when a number is divided by another i.e. 7 mod 4 = 3 i.e. 7/4 = 1 remainder 3

    this is useful for calculating odd or even mod 2
    chaos theory etc
    but is probably more in use in coding theory such as ISBN numbers
    i can go into a bit more detail if anyone is interested

    Dave

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I've just revisited the code and you will have a problem if ther NoClockings is null, it returns a remainder (ie indicates clocked in), rather than the clocked out state I would expect

  6. #6
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    Just set up another if statement to encolse your other ones i.e.
    If Not IsNull(NoClockings) or NoClockings <> "" then
    if (NoClockings mod 2)=1 then
    'insert code for still logged in
    else
    'insert code for logged out
    endif
    Else
    'case for null values
    End IF

    OR

    CurrentState=iif(noClockings is Not Null,"Clocked " & iif((NoClockings mod 2)=0,"Out","In"),"Null Clockings")

    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •