Results 1 to 2 of 2
  1. #1
    Hasher is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2013
    Posts
    13

    TimeValue in Excel VS Access VBA

    Hi guys,
    I was looking at some code in a database that I inherited. Seems the previous guy was trying to use TimeValue function to Convert a serial and this just throws up errors. In Excel this is the intended use. Could anyone tell me if there is a equivalent inbuilt function in MS access ?

    This is the code I'm working with. Any help is appreciated


    Code:
        Dim dblHoursWorked As Double    Dim dblOvertime As Double
        Dim intHoursWorked As Integer
        Me.txtOverTime = ""
        Me.txtDoubleTime = ""
        Me.txtOrdTime = ""
        
        
      If (Nz(Me.txtStartTime) <> "" And Nz(Me.txtFinishTime) <> "") Then
              intHoursWorked = DateDiff("h", Format(Me.txtStartTime, "HH:MM"), Format(Me.txtFinishTime, "HH:MM"))
              dblHoursWorked = (TimeValue(Format(Me.txtFinishTime, "HH:MM")) * 24) - (TimeValue(Format(Me.txtStartTime, "HH:MM")) * 24) - txtTimeOff


  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    There is a TimeValue function in A2010 (don't know about A2007), and it converts a time expression in a string to a time in a Date type.

    I'm not sure you need that though. If dblHoursWorked is meant to show hours worked as decimal hours, you could use:

    DateDiff("n", Format(Me.txtStartTime, "HH:MM"), Format(Me.txtFinishTime, "HH:MM")) / 60.0

    But looking at the expression you have for dblHoursWorked, I don't see what it is doing.

    HTH

    John

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

Similar Threads

  1. =TimeValue(Now()) Not Running Live
    By excellenthelp in forum Access
    Replies: 3
    Last Post: 06-27-2014, 01:19 PM
  2. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  3. Replies: 10
    Last Post: 12-28-2012, 02:06 PM
  4. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  5. TimeValue
    By turnbuk in forum Queries
    Replies: 9
    Last Post: 08-10-2011, 02:44 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