Results 1 to 4 of 4
  1. #1
    CSUjr is offline Novice
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    4

    Question Module that caculates the difference between times

    First, I'm running Windows 7 and working in Access 2007.



    I'm new at VBA programming and creating Modules so I'd like to ask for some help with creating a Module that caculates the difference between times and then populates a field in the Table, the Form and the Report.

    I am creating an Access database for some Tractor Trailer Logs.

    This Access database is based on data imported from an Excel spreadsheet.

    One of the fields in the Excel spreadsheet is labeled [Trip Time](T).

    This field is populated through a simple arithmatic formula that subtracts values from two previous fields, which are, [Start Time](R) & [End Time](S).

    The format of those fields, [Start Time](R) & [End Time](S), is h.mm AM/PM

    The formula (in Excel) that populates [Trip Time](T) reads (=Snn - Rnn) and the output format of that field is (Short Time) h.mm, for instance 2:30 (2 1/2 hours).

    So being somewhat new to Access 2007 and having no experience creating Modules, I'd like to ask for some help to;

    1. Create a working Module that;
    a. uses a single date - or uses the same date twice. (because the Logs currently show all trips occuring on the same date)
    b. that does not use Seconds (.ss) in the caculations

    2. If necessary, how to tailor the Code to work correctly with the existing labeled fields ([Date], [Start Time], [End Time], [Trip Time].

    3. How and where to implement the Module so that the [Trip Time] field is populated in the Table, the Form and the Report.

    (If only within the Form during data entry, then how can I make it so that the [Trip Time] field is also popualted within past, existing Log entries?)

    With appreciation,
    Charles

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    look at the datediff() function. combining it with the format() function might just help you out. you don't need a module. these functions do it all

  3. #3
    CSUjr is offline Novice
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    4

    Thank you

    Thank you for your reply.

    If a combination of these two functions will populate the desired fields, do I have to use them in the Table, the Form and the Report - or just the Form?

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by CSUjr View Post
    Thank you for your reply.

    If a combination of these two functions will populate the desired fields, do I have to use them in the Table, the Form and the Report - or just the Form?
    use them where ever you want. most commonly on forms. you can't in a table.

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

Similar Threads

  1. Difference between load and open
    By Helen in forum Forms
    Replies: 2
    Last Post: 07-15-2010, 02:13 AM
  2. Count difference between two dates
    By Costa in forum Forms
    Replies: 3
    Last Post: 03-09-2010, 10:38 AM
  3. Difference between 2 identical tables.
    By leepan2008 in forum Access
    Replies: 1
    Last Post: 09-28-2009, 07:36 PM
  4. difference between drivers
    By tomc1 in forum Access
    Replies: 0
    Last Post: 08-04-2009, 10:41 AM
  5. Time difference
    By jguidry in forum Programming
    Replies: 1
    Last Post: 11-15-2008, 12:41 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