Results 1 to 6 of 6
  1. #1
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    122

    limit number of hours entries per day

    Dear Gents,


    I have a time sheet application and trying to limit users to enter only 8 hours per day , if the value was more than 8 it shows pop up window " You can't enter more than 8 hours per day "

    here is my code to solve this problem except that i can't specify the date

    Code:
    Private Sub Hours_AfterUpdate()
    If Me.Hours.Value > 8 Then
    Me.Add_Record.Enabled = False
    MsgBox "You are trying to add more than 8 hours / Day , Please use overtime box if you are trying to add overtime hours", vbInformation
    Else
    Me.Add_Record.Enabled = True
    End If
    End Sub

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,999
    Quote Originally Posted by shod90 View Post
    ...i can't specify the date...
    We really need more info to help you. Why do you need to specify the date? There should be a separate Record for each employee each day.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,764
    I would assume this record was date-specific, so in what way do you need to add a date test?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    122
    Quote Originally Posted by Missinglinq View Post
    We really need more info to help you. Why do you need to specify the date? There should be a separate Record for each employee each day.

    Linq ;0)>
    Okay you are right , But what if the user entered 2 records in day each with 4 hours so the total of the day will be 8 hours.
    that's why i need to specify date , on ( each ) date should be only 8 hours , No matter if he entered the same date 2 or 3 or maybe more but the most important is this date for this user can't be more than 8 hours.

  5. #5
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    122
    Quote Originally Posted by pbaldy View Post
    I would assume this record was date-specific, so in what way do you need to add a date test?
    As i said to missinglinq , Suppose the user entered the date more than one time ? , I need to limit the date of the day as example: the user entered on the begining of the day 2 hours , then he again opened the database and entered 2 more hours , now the total is 4 hours in this day so he still have 4 hours remaining , After entering the 4 hours the add record button should be disabled.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,764
    You can use a DSum() with the appropriate criteria:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Limit number of entries into nested subform?
    By shadowbh2 in forum Programming
    Replies: 7
    Last Post: 11-28-2014, 11:03 PM
  2. Number of Calls during business hours
    By desireemm1 in forum Queries
    Replies: 20
    Last Post: 10-29-2014, 06:24 PM
  3. Limit entries on a report
    By Derrick T. Davidson in forum Reports
    Replies: 3
    Last Post: 03-17-2013, 09:33 PM
  4. Calculating Overtime hours from Time entries
    By weshader in forum Programming
    Replies: 3
    Last Post: 11-13-2011, 01:08 AM
  5. Replies: 1
    Last Post: 10-22-2010, 01:29 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 - Senior Forums