A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert Short time to decimals



 
 
Thread Tools Display Modes
  #1  
Old June 22nd, 2007, 10:03 AM posted to microsoft.public.access.gettingstarted
chad
external usenet poster
 
Posts: 631
Default 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  
Old June 22nd, 2007, 12:34 PM posted to microsoft.public.access.gettingstarted
missinglinq via AccessMonster.com
external usenet poster
 
Posts: 545
Default 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  
Old June 22nd, 2007, 12:36 PM posted to microsoft.public.access.gettingstarted
missinglinq via AccessMonster.com
external usenet poster
 
Posts: 545
Default 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  
Old June 22nd, 2007, 12:51 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old June 22nd, 2007, 02:38 PM posted to microsoft.public.access.gettingstarted
missinglinq via AccessMonster.com
external usenet poster
 
Posts: 545
Default 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  
Old June 22nd, 2007, 06:32 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default 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  
Old June 22nd, 2007, 07:16 PM posted to microsoft.public.access.gettingstarted
missinglinq via AccessMonster.com
external usenet poster
 
Posts: 545
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.