Results 1 to 8 of 8

Thread: MS Access VBA help

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    44

    MS Access VBA help

    hi guys.
    i'm trying to create a access database with vba coding for a attendance notebook whereby it will do the calculations for the attendance percentage upon changes made in the field

    e.g.

    john mary harry tom ken
    DAY1 P P P P P
    DAY2 P P A A A
    DAY3 A A P P P
    DAY4 P P P P A
    DAY5 A P P P P

    percentage 60% 80% 80% 80% 60%


    what i mean is, if i were to change the number of days, and change the no. of P(present) and A(absent)
    the field in the percentage rows will automatically calculate the percentage of the attendance for that particular row.

    is this possible? thx for ani enlightening help

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: MS Access VBA help

    Table of attendees
    AttendeeID - auto
    AttendeeFN - text (forename)
    AttendeeSN - text (surname)
    other info fields

    Table of DaysMeetings
    DaysMeetingsID - auto
    MeetingDate - date
    AttendeeID - number - long
    Status - text (1) - P or A

    link the two tables in the querybuilder and use the sum button (backwards E at the top).
    For each day you need to get the count of Ps and As

    Sql statement might be something like:
    Code:
    Select
        MeetingDate,
        count(Status=P) as Present,
        count(Status=A) as Absent,
        count(Status=P)/(count(Status=P)+count(Status=A) as PercentagePresent
    From 
        DaysMettings
    Group By
        MeetingDate
    This is very rough, from my head and I'm not feeling well so it probably won't work. If I'm feeling better tomorrow I'll try an example of it in a db and post up if it works.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: MS Access VBA help

    Hi

    Attached is a possibility for this type of project using your test data.

    However I think you should rethink it and find a better way to display/enter the data.

    I'm not sure is there will be a significant increase in processing should there be lots of people/meetings and I think that there is probably something else wrong (but I cannot put my finger on it).

    Anyway, take a look if you wish, use at you own peril
    Attached Files Attached Files

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    44

    Re: MS Access VBA help

    hey thx.
    but erm. actually im trying to calculate the percentage of the attendance for each individual over a period of time...
    sorry if i din make myself clear

  5. #5
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: MS Access VBA help

    Possibly?
    Code:
    Select
       Person,
       Count(Attendence='P') as TotalPresent,
       Count(Attendence='A') as TotalAbsent,
       Format(TotalPresent/(TotalPresent+TotalAbsent),'#0%') AS PercPresent
    From
       tableofdata
    Where
       DateField between #01 Jan 2005# and #01 Feb 2005#
    If that doesn't run or runs but incorrectly, then it probably would need to be sub queries for the counts, by person and the main select would use those results to perform the calculation...


    If you want the calculation as well as the totals, it wouold be better to fill the control by code and then run from top row to last row of hte display control totalling up, entering these into an array or into the control as the last row...

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    44

    Re: MS Access VBA help

    many thx for your help
    i have attached a sample of my database after sorting out a better layout of the attendance...could you help me with it?
    im realli sorry, im a complete VBA and SQL idiot.

    P = present
    A = absent
    L = late (present)
    VL = very late (absent)
    NA = date will not be counted in the percentage
    Attached Files Attached Files
    Last edited by Asakura; Apr 9th, 2005 at 02:59 AM.

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    44

    Re: MS Access VBA help

    help? ani1 ?

  8. #8
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: MS Access VBA help

    Read up on normalisation.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width