Results 1 to 6 of 6
  1. #1
    princess12 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    79

    convert hours into minutes

    Hi everyone,


    so i am trying to convert hours into minutes in textbox, and it not working

    here is what i tried

    Me.textbox1= Format(me.txthours, "h") * 60 + Format(me.txthours, "n")


    Me.textbox1= (Hour(Me.txthours) * 60) + Minute(Me.me.txthours)

    please guide me the right way

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The txtHours is not already in hours....what is it? A date/time?
    is it an integer of hours?

  3. #3
    princess12 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    79
    it calculated from a listbox column a total but in time format hh:nn

    this works if i put it in control source but i need the code in vba so all my formulas work apart from this one

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you can't multiply text values, you need to convert them to a number first

    try
    Me.textbox1= val(Format(me.txthours, "h")) * 60 + val(Format(me.txthours, "n"))

  5. #5
    princess12 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    79
    sorry for the trouble, i just moved this line Me.textbox1= (Hour(Me.txthours) * 60) + Minute(Me.me.txthours) after listbox calculation, it was before, that why it didnt work. thanks a lot.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Ajax, actually Access/VBA will do math on text values if it can recognize the values as numeric. There can be issue with addition because + character is also valid for concatenation (holdover from ancient BASIC). If both values are text, will concatenate.
    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-12-2013, 10:20 AM
  2. Converting minutes into hours in report
    By jinro in forum Access
    Replies: 13
    Last Post: 04-01-2013, 07:06 PM
  3. Converting Minutes Into Hours
    By KellyM in forum Reports
    Replies: 8
    Last Post: 04-23-2012, 12:49 PM
  4. Overall Total of Hours & Minutes in Report
    By StevenCV in forum Reports
    Replies: 1
    Last Post: 02-27-2012, 10:48 AM
  5. How to calculate duration in hours & minutes
    By joypanattil in forum Access
    Replies: 0
    Last Post: 11-25-2009, 04:49 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