Convert Short time to decimals

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!!
 
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
 
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
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
 
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.
 
Thanks for the explanation, Doug!
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]
 
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]
 
Back
Top