If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Convert Short time to decimals
Hello, I have a form named frmDecimalConversion. And on this form I have two
text boxes (txtMinutes and txtDecimal) the txtMinutes you enter your minutes into and the txtDecimal wil convert to decimals. Example: 480 minutes (typed into txtMinutes) will give you a result of 8 in the txtDecimal box Here is the code in the After Update in the txtMinutes box. Private Sub txtMinutes_AfterUpdate() Me.txtDecimal = Round(Me.txtMinutes / 60, 2) End Sub Everything works great except I want to change from minutes to short time (Example) 4:45 typed into txtMinutes box will result in 4.75 in the txtDecimals box. Can someone help me on the VBA code for the formula? instead of the Me.txtDecimal = Round(Me.txtMinutes / 60, 2) Thanks!! |
#2
|
|||
|
|||
Convert Short time to decimals
There may be an easier way, but this does it:
Me.txtDecimal = Format(Me.TxtMinutes, "h") & Format((Minute(Me.TxtMinutes) / 60), ".##") -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...arted/200706/1 |
#3
|
|||
|
|||
Convert Short time to decimals
I wish someone could explain to me why, with all the space left in the margin,
this forum split that line of code! Make sure that the code I gave you is all on one line! missinglinq wrote: There may be an easier way, but this does it: Me.txtDecimal = Format(Me.TxtMinutes, "h") & Format((Minute(Me.TxtMinutes) / 60), ".##") -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...arted/200706/1 |
#4
|
|||
|
|||
Convert Short time to decimals
You have to remember that, regardless of how you're posting to this
newsgroup, it's an NNTP newsgroup under the covers. Traditionally, line lengths in NNTP are limited to 76 characters. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "missinglinq via AccessMonster.com" u28780@uwe wrote in message news:7413bcaca37f9@uwe... I wish someone could explain to me why, with all the space left in the margin, this forum split that line of code! Make sure that the code I gave you is all on one line! missinglinq wrote: There may be an easier way, but this does it: Me.txtDecimal = Format(Me.TxtMinutes, "h") & Format((Minute(Me.TxtMinutes) / 60), ".##") |
#5
|
|||
|
|||
Convert Short time to decimals
Thanks for the explanation, Doug!
Douglas J. Steele wrote: You have to remember that, regardless of how you're posting to this newsgroup, it's an NNTP newsgroup under the covers. Traditionally, line lengths in NNTP are limited to 76 characters. I wish someone could explain to me why, with all the space left in the margin, [quoted text clipped - 7 lines] / 60), ".##") -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
#6
|
|||
|
|||
Convert Short time to decimals
On Fri, 22 Jun 2007 02:03:01 -0700, Chad
wrote: Everything works great except I want to change from minutes to short time (Example) 4:45 typed into txtMinutes box will result in 4.75 in the txtDecimals box. Can someone help me on the VBA code for the formula? instead of the Me.txtDecimal = Round(Me.txtMinutes / 60, 2) Try: Round(DateDiff("n", #00:00:00#, CDate(Me.txtMinutes)) / 60, 2) John W. Vinson [MVP] |
#7
|
|||
|
|||
Convert Short time to decimals
That'll work, too! Anybody have a third way?
-- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|