Results 1 to 3 of 3
  1. #1
    donnan33 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    52

    Date/Time Field

    I have a timesheet in access with the following fields.



    starttime
    timeout1
    tinein1
    timeout1
    timein2
    finishtime


    Everything is working great. Except for it is possible for them to enter the wrong time. For instance,

    07:00am - starttime
    11:00pm - timeout1 should be 11:00am
    12:00pm = time in 1
    5:00pm - finish time

    they input wrong time and put pm instead of am making it 21 hours instead of 9 hours total for the day. is there a way to code or setup so that the user doesn't enter wrong time?

    Any help greatly appreciated.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    It won't be possible to cover all scenarios, but you can put some validation in place. You need to think of all possible errors that can occur and then handle them. Here is some VBA code as an example:

    In the AfterUpdate event for the form, put code like this:

    If Not IsNull(me!starttime) then
    if not isnull(me!timeout1) then
    if me!starttime > me!timeout1 then
    errcode=1
    exit sub
    end if
    endif
    if not isnull(me!finishtime) then
    if me!starttime > me!finishtime then
    errcode=1
    exit sub
    end if
    etc
    etc

  3. #3
    Othy is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    4
    You can also, in each field, set up an "on click" event that automatically inputs the time when they click in that field. This way they don't have to enter the time themselves. That is how I have a time sheet here setup.

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

Similar Threads

  1. date/time field calculations
    By donnan33 in forum Queries
    Replies: 4
    Last Post: 01-13-2012, 11:58 AM
  2. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM
  3. Date/Time Field Query...
    By Coffee in forum Queries
    Replies: 5
    Last Post: 07-05-2011, 11:27 PM
  4. Access 2007 Date/Time Field
    By cdh in forum Access
    Replies: 3
    Last Post: 05-12-2011, 07:11 AM
  5. date/time field
    By James890 in forum Database Design
    Replies: 1
    Last Post: 04-18-2007, 07:51 AM

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