converting time to decimal number

Marta

Registered User.
Local time
Yesterday, 22:59
Joined
Apr 8, 2011
Messages
16
Hi
I need to convert time to a decimal number after I insert it. I have found a function to do that in a book.

Code:
Function IndT(T As Date) As Single
IndT = T * 24
End Function
Sub ConvertTime()
MsgBox IndT([fieldname])
End Sub
It works but it is not what I really need. I have a number field in a table and I want time to change to decimal number after I inset the time (for example 3:45 to 3,75). I don't need message box I need those numbers inset to the table.
I hope you understand my question and thank you very much for your help.
 
Last edited:
If you want to store the number as a decimal you'll need to use a field size of Single. However, you won't be able to enter 3:45 in a field of this type, so you would probably need to add an unbound text box on your form (let's call it txtEnterTime) and in the AfterUpdate event of that text box do something like the following;

Me!YourField = TimeValue(Me!txtEnterTime) * 24
 

Users who are viewing this thread

Back
Top Bottom