Rick's News said:
The problem is if I declare that LngStart = 0 and the difference in days
between current day and four days ago gets tacked on to [leaveend] on the
report because it starts from 0 and moves over from 0 instead of - 4
days...
Yes, of course. I really am being dense, not just today,
but all week :-( I should have caught that right at the
beginning. Sorry to cause so much confusion.
It looks like we need to expand on what you started with and
keep track of the adjusted LeaveStart date to use in the
duration calculation. Anyway, here's the code I came up
with for a test form to do at least some of what I think
you're trying to do:
Dim lngDuration As Long 'days of leave
Dim lngStart As Long 'start date of leave
Dim dteStartLeave As Date
Dim lngLMarg As Long
Dim dblFactor As Double
'put a line control in your page header that starts 1/1 and
goes to 12/31
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 30
If Me.[LeaveStart] > Date + 29 _
Or Me.LeaveEnd < Date Then
Me.txtname.Visible = False
Exit Sub
End If
If Me.[LeaveStart] < Date Then
dteStartLeave = Date
lngStart = 0
Else
dteStartLeave = Me.[LeaveStart]
lngStart = DateDiff("d", Date, dteStartLeave)
End If
If Me.LeaveEnd > Date + 29 Then
lngDuration = DateDiff("d", _
dteStartLeave, Date + 29) + 1
Else
lngDuration = DateDiff("d", _
dteStartLeave, Me.LeaveEnd) + 1
End If
Me.txtname.Visible = True
Me.txtname.Width = 0
Me.txtname.Left = (lngStart * dblFactor) + lngLMarg
Me.txtname.Width = lngDuration * dblFactor
--
Marsh
MVP [MS Access]
Pasted code:
Dim lngDuration As Long 'days of leave
Dim lngStart As Long 'start date of leave
Dim lngLMarg As Long
Dim dblFactor As Double
'put a line control in your page header that starts 1/1 and goes to
12/31
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 30
If Me.[LeaveStart] < Date Then
lngStart = 0
lngDuration = DateDiff("d", (Me.[LeaveStart] - Date), Me.[LeaveEnd]) + 1
Else
lngStart = DateDiff("d", Date, Me.[LeaveStart])
End If
If Me.LeaveEnd > Date + 30 Then
lngDuration = DateDiff("d", Me.LeaveStart, Date + 30) + 1
Else
lngDuration = DateDiff("d", Me.LeaveStart, Me.LeaveEnd) + 1
End If
Me.txtname.BorderColor = 255
Me.txtname.BackColor = 255
Me.txtname.Width = 5 'avoid the positioning error
Me.txtname.Left = (lngStart * dblFactor) + lngLMarg
Me.txtname.Width = (lngDuration * dblFactor)
Me.MoveLayout = False
Rick's News wrote:
Sorry Marshall,
Rick's News wrote:
This is an example of what I want:
Today = 22 Nov 03
LeaveStart = 20 Nov 03
Leave End = 28 Dec 03
If I print the report today and today is 22 Nov 03 then I want the
report
to
only color these days = 22 Nov 03 - 21 Dec 03
I don't want the extra days on this report... Just the current 30 day
forecast...
"Marshall Barton" wrote
I must be particularly dense today. I thought that
If Me.LeaveEnd > Date + 30 Then
lngDuration = DateDiff("d", Me.LeaveStart, Date + 30)+1
Else
lngDuration = DateDiff("d", Me.LeaveStart, Me.LeaveEnd)+1
End If
did just what you're asking about. If you are using
different code, then please copy/paste the current code so I
can see what you have. If that is what you have, what is it
doing that you don't want it to do?
--
Marsh
MVP [MS Access]
Rick's News wrote:
Sorry, The error was in the Query behind the report.
But now that I can view the report I need to find a way to display
this...
The Report shows me personnel's vacation days on a continuous 30
rotation.
If I open the report today I should see everyone On leave where the leave
start date started before 22 November, but only "paint" the
Me.[boxTimeLine]
starting with the current date. However I still need it to count from
the
original [leavestart] to accurately show the [leaveend].
You're losing me here. Does this mean that the problem with
positioning the text is OK, or are we still working on the
same issuers?
If this is a different problem, what result are you looking
for and what are you getting?
Rick's News wrote:
If leave start = 20 November and today is 22 November I need the leave
start
to show 22 November.
If leave end = 24 December the stop at 22 December because it will cause
an
overflow error and there is know place to paint the days.
But LeaveStart is the number of days after today when the
vacation starts, isn't it??
Thanks for helping me. I hope I explained enough details to you.
Let me know if I need to explain this further.
The code works but it adds from [leavestart] = 0 and not from the
original
day.
What do you mean by "adds from" ?
What is the original day?
Rick's News wrote:
I can't get this to work... It is a report that will have dates
outside of what I want to display.
It is supposed to move the text box TIMELINE width for the given
days.
However, I only want to show the current days on the report, even
if
the leavestart is before today's date or leave end is after today +
30 days.
Can someone please help me...
Dim lngDuration As Long 'days of leave
Dim lngStart As Long 'start date of leave
Dim lngLMarg As Long
Dim dblFactor As Double
'put a line control in your page header that starts 1/1 and
goes
to 12/31
lngLMarg = Me.boxTimeLine.Left
dblFactor = Me.boxTimeLine.Width / 30
If Me.LeaveStart < Date Then
lngStart = Date
Else
lngStart = DateDiff("d", Date, Me.LeaveStart)
End If
If Me.LeaveEnd > Date + 30 Then
lngDuration = Date + 30
Else
lngDuration = DateDiff("d", Me.LeaveStart,
Me.LeaveEnd)
+ 1
End If
Me.txtname.BorderColor = 255
Me.txtname.BackColor = 255
Me.txtname.Width = 5 'avoid the positioning error
Me.txtname.Left = (lngStart * dblFactor) + lngLMarg
Me.txtname.Width = (lngDuration * dblFactor)
Me.MoveLayout = False
You set lngStart and lngDuration to a date value in the true
part of the If, but you expect it to contain a number of
days.
I think you want to use
If Me.LeaveStart < Date Then
lngStart = 0
Else
lngStart = DateDiff("d", Date, Me.LeaveStart)
End If
If Me.LeaveEnd > Date + 30 Then
lngDuration = DateDiff("d", Me.LeaveStart, Date + 30)+1
Else
lngDuration = DateDiff("d", Me.LeaveStart, Me.LeaveEnd)+1
End If