Results 1 to 9 of 9
  1. #1
    Beltramo64 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    12

    Need help with conditional format with multiple fields (Weekly field) and (ManppowerID)


    I want to create an conditional format that will do the following:

    For each manpowerID ie.. person, if the sum of a field for a particular week is >= 40 (hrs) then Make the background green.

    This currently works Expression is [AS1/18]>=40, but if a person is working on more than one job per week it does not work, so I want it to be the sum of the field [AS1/18], then make the background green. But I can't get it to work. Any ideas


    thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Use DSum() domain aggregate in the Conditional Formatting rule. Need some value that identifies the week period.

    Expression Is: DSum("[AS1/18]", "tablename", "manpowerID=" & [manpowerID] & " AND [weekID]=" & [weekID]) >= 40

    Or do the DSum() calc in query and reference that constructed field in the rule. If this is for a report, instead of DSum() can use an aggregate query that does the summary calc and join that query to the data with compound link on ID fields.

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Beltramo64 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    12
    it works if my sum adds up to 40 or more on one job, however if the man works on 2 or 3 customers jobs within the week, hence 3 separate inputs for the same person it does not work. maybe I need to add in the conditional format the customerID? What would that formula look like thanks in advance,

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Why not base your form or report on an aggregate query?
    Group by CustomerID and sum the hours for that week
    Then apply conditional formatting on that.

    EDIT - oops - missed that June had already suggested this in post 2

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The suggested DSum() should add all hours for employee in given week regardless of the jobs.

    Adding the customerID as criteria would require sum to be >= 40 for each employee/customer/week combination for field to be green. If that's what you want then go ahead. Include as many criteria in the DSum() (or aggregate query) as needed to get the desired result.

    And one approach for using aggregate query presented in post 2. The more grouping criteria, the more links in joining datasets. Depends on what level detail you want to display in the report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Beltramo64 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    12
    Alright I am getting closer to what I want, but need some assistance, I have created a form where I can input the hours per week for each employee. What is the following 2 formulas:

    1. In the conditional format, for example under field [AS1_18] I want an expression that once the sum of the field ie... [AS1_18]=40, for a particular employee [ManpowerID], to make it green. Please note that in the table where you are inputting the hours for a particular week ie.. [AS1_18] there can be more than one input under the AssignedID Field that would add up to 40 hours. This is very important in the Form, because some managers share the same workers and I need the managers to know (visually through it being green) that, a man may not be available, hence his total is green. Which leads me to my
    2nd request.
    2. in the same field ie... [AS1_18] a formula/expression in the validation rule that only allows for one [ManpowerID] to have a sum of 40 hours (obviously the you can have more than one [AssignedCalendarID] adding up to a total of 40 hours) under the field ie... [AS1_18]. If the sum exceeds 40 hours, validation text will be displayed to says "the man has already been used for this week".


    Thanks in advance,
    Currently using the expression for conditional formatting for field AS1_18 and it does not work
    DSum("[AS1/18]","TBL_AssignedCalendar","manpowerID=" & [manpowerID] & " AND [AssignedCalendarID]=" & [AssignedCalendarID])>=40



    Click image for larger version. 

Name:	pictureofdatabase.JPG 
Views:	10 
Size:	88.6 KB 
ID:	31808

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The field name is AS1_18 not AS1/18.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Beltramo64 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    12
    yes, you are correct it works now. any thoughts on the 2nd request

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    So in addition to the color of textbox, you want a popup message?

    I don't know enough about your data structure and form design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 06-19-2017, 10:39 AM
  2. Conditional Format Change Field Value
    By leanbiz in forum Access
    Replies: 3
    Last Post: 12-07-2015, 12:41 PM
  3. weekly timetable report format
    By merlin777 in forum Reports
    Replies: 14
    Last Post: 10-27-2014, 11:06 AM
  4. Replies: 2
    Last Post: 01-08-2013, 04:59 PM
  5. Replies: 1
    Last Post: 07-20-2011, 01:24 PM

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