form field update from time fields

J

James Griffin

I am using the following VBA code to update time difference entered values -
the code is neraly working however the "TotalTime3" double field has the
correct time in terms of decimal hours but when it assigns it to the form
control "Me.totalhours.Value = TotalTime3" I am getting 13 for
Me.totalhours.Value and 14 for Me.totalhours.Text. I feel there is some
rounding or flooring going on and instead the answer should be 13.5 hours
what do i need to do to ensure this ? I then assign this value to a table.
Should I use code to look either side of the decimal point or is there a
property within the field control ? I have a new book Access 2007 inside and
out and realise the note about decimal points and I have set the field format
property to standard number and read that it should be outputting two decimal
points but instead its just a whole number such as the 13 or 14 and I wish
13.5 or 13.38 for example ......can anyone help please

Private Sub Cmd_sum_total hours()

Dim TotalTime3 As Double


Set DB = CurrentDb
Set rst = DB.OpenRecordset("Clock_Table")



TotalTime3 = ((([ClockoutDay1] - [ClockinDay1])) + (([ClockoutDay2] -
[ClockinDay2])) + (([ClockoutDay3] - [ClockinDay3])) * 24 + (([ClockoutDay4]
- [ClockinDay4]))) * 24


Me.totalhours.DecimalPlaces = 2
Me.totalhours.SetFocus
Me.totalhours.Value = TotalTime3


The answer I am getting
 
J

James Griffin

From changing the "totalhours" number property of the associated table.field
the problem was solved - although slightly inaccurate from multiplication of
truncated value ! I work out how to convert the decimal minutes into base 60.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top