The lngDuration memory variable is used to capture/store the number of hours
from the start to finish of an event (duration). The results returned from
DateDiff() are always integers (whole numbers with no decimal).
You wanted half hours (or better) so the lngDuration needed to be changed to
accomodate fractions/decimals. The "As Long" wouldn't allow for storing
decimals while "As Double" does.
The "h" or "n" in DateDiff() is to return the duration in either Hours or
Minutes ("m" is month).
The code changes find the difference in minutes and divides by 60 to convert
to the number of hours with decimals.
--
Duane Hookom
Microsoft Access MVP
:
Worked like a champ. But if you don't mind two questions:
1. difference between "long" and "double"
2. why the change between the "h" and "n"
Thanks for your help. I just don't want to put code in that I don't totally
understand.
:
I think you need to change
Dim lngDuration As Long 'hours of work
lngDuration = DateDiff("h", Me.[start], Me.[end])
to
Dim lngDuration As Double 'hours of work
lngDuration = DateDiff("n", Me.[start], Me.[end])/60
--
Duane Hookom
Microsoft Access MVP
:
I have the following code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim lngDuration As Long 'hours of work
Dim lngStart As Long 'start hour of tour
Dim lngLMarg As Long
Dim dblFactor As Double
'put a line control in your page header that starts 12:00 and goes to
23:00
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 24
lngStart = DateDiff("h", #12:00:00 AM#, Me.[start])
lngDuration = DateDiff("h", Me.[start], Me.[end])
'set the color of the bar based on a data value
Me.txtName.Width = 10 'avoid the positioning error
Me.txtName.Left = (lngStart * dblFactor) + lngLMarg
Me.txtName.Width = (lngDuration * dblFactor)
Me.MoveLayout = True
End Sub
However, I have some employees who start or end on the half hour and this
places them on the full hour. How do I go about changing it so the timeline
will reflect 1/2 hours?
:
Glad to hear you got this working. Come back if you have questions since you
have the attention of the author ;-)
--
Duane Hookom
Microsoft Access MVP
:
Great ... both the new link and the "unblock" worked so now I can attempt it.
Thanks so much for your help.
:
The invisibleinc file is now located at
http://www.access.hookom.net/Samples.htm. Most files you download from the
intranet have a property set that you need to change so you can open them.
After downloading, right-click the file and choose Properties. I think the
property is like "unblock".
--
Duane Hookom
Microsoft Access MVP
:
I'm looking for instructions on how to do a Gantt Timeline. I've gone to
this suggested website ...
http://www.invisibleinc.com/divFiles.cfm?divDivID=4 ... but the link doesn't
work. Then I went here ...
http://mvps.org/access/reports/rpt0018.htm and
downloaded the files, but when I go to open the database, it tells me I must
install the database on my computer . Exact phrase: File is located on an
intranet or untrusted site. Not so, opening it from the C: drive.
So I'm still looking, any help would be appreciated.
Margaret