Results 1 to 3 of 3
  1. #1
    jackjfarrell is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Jun 2016
    Posts
    3

    Adding records with VBA

    I am creating a database for workorders and keeping time. I have everything the way I want it except for a way to track that managers time. They managers time is split up equally between all workorders that his crew has put time on that day. For example if they crew worked 100 hours on June 21st and they worked 15 hours on Workorder 1, 15% of the managers time would be applied to workorder 1. Siminarly if they worked 25 hours on workorder 2 on the 21st then 25% of the managers time is applied to workorder 2.



    I can do this using excel but it is a pain to export the data from access and then go back in access and add time to each of the workorders for the manager. (This is a large scale operation and there are often times 25-35 workorders per day.

    Is there a way to use VBA to add up the crews total time for the day, divide by each workorder to see the % of time worked on each workorder for the day and then create a record for the manager with that percentage of his time? The manager is identified by the WWID field.

    I know its a little complicated (or at least it seems that way to me). I really appreciate your help.
    Attached Thumbnails Attached Thumbnails Workorder.jpg   Time.jpg  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you should be able to do this with queries, not vba.
    1.a sum qry for the crews / day , a make table qry to write to a temp table
    2. then apply this sum to each manager using an update query.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is there a way to use VBA to add up the crews total time for the day, divide by each workorder to see the % of time worked on each workorder for the day and then create a record for the manager with that percentage of his time?
    Yes, of course.

    You would create a query (in VBA) to get sum of the hours worked by WO number for the crew of the manager ID and the date.
    Add up all of the hours, then loop by WO, do the division, calculate the hours and insert the manager's hours.

    Basically the same way you do it in Excel or manually.

    The next problem is how/when to execute the code. And for how many/what days? (text box on a form to select the day??)


    BTW, "TIME" is a reserved word in Access and shouldn't be used as object names.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding records
    By Srin in forum Access
    Replies: 17
    Last Post: 10-26-2015, 07:57 AM
  2. Adding records with subforms
    By rwest in forum Forms
    Replies: 3
    Last Post: 12-21-2011, 03:44 PM
  3. adding records
    By jwallace203 in forum Forms
    Replies: 3
    Last Post: 07-18-2011, 10:00 PM
  4. Replies: 10
    Last Post: 01-10-2011, 07:52 PM
  5. Adding Records
    By Rick West in forum Forms
    Replies: 7
    Last Post: 05-17-2010, 02:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums