By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,442 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

What is wrong with this VBA code?

P: n/a
I downloaded TimeLines.zip from
(http://www.mvps.org/access/reports/rpt0018.htm) and I think I found a
bug in it but I can't seem to fix it. When you open this go to the
table and enter a new event and put it's start date at like12/01/1999
and the end date at 12/31/1999. Then go to the report and find your new
entered event. If it does what it does on my computer you will notice
that for some reason the bar is in the wrong place. I'm guessing that
it has something to do with the math in the detail_Format section. The
report is perfect for what I need but if you put in an event in the
latter half of the timeline it doesn't seem to show correctly on the
chart. Any Ideas.
Thanks
Shawn Yates

Jul 18 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a

Oops I forgot to post the VBA code here is all of it:

Option Compare Database
Option Explicit

Private mdatEarliest As Date
Private mdatLatest As Date
Private mintDayDiff As Integer
------------------------------------------------------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

On Error Resume Next

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
Me.boxGrowForDate.Visible = True
Me.lblTotalDays.Visible = True
intStartDayDiff = Abs(DateDiff("d", Me.StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", Me.EndDate, Me.StartDate))

If intStartDayDiff = 0 Then intStartDayDiff = 1
With Me.boxGrowForDate
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor
End With
Me.lblTotalDays.Left = Me.boxGrowForDate.Left
Me.lblTotalDays.Caption = intDayDiff & " Day(s)"
Else '
Me.boxGrowForDate.Visible = False
Me.lblTotalDays.Visible = False
End If
End Sub
---------------------------------------------------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Min([Start Date]) AS MinOfStartDate
" _
& " FROM Projects", dbOpenSnapshot)
If rs.RecordCount 0 Then
mdatEarliest = rs!MinOfStartDate
End If
Set rs = db.OpenRecordset("SELECT Max(IIf(IsDate([End
Date]),CDate([End Date]),Null)) " _
& "AS MaxOfEndDate FROM Projects", dbOpenSnapshot)
If rs.RecordCount 0 Then
mdatLatest = rs!MaxOfEndDate
End If

mintDayDiff = DateDiff("d", mdatEarliest, mdatLatest)

Me.txtMinStartDate.Caption = Format(mdatEarliest, "mm/dd/yyyy")
Me.txtMaxEndDate.Caption = Format(mdatLatest, "mm/dd/yyyy")
Set rs = Nothing
Set db = Nothing
End Sub

Jul 18 '06 #2

P: n/a
Classic bug, the left position is set before the width.

So
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor

Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
I downloaded TimeLines.zip from
(http://www.mvps.org/access/reports/rpt0018.htm) and I think I found a
bug in it but I can't seem to fix it. When you open this go to the
table and enter a new event and put it's start date at like12/01/1999
and the end date at 12/31/1999. Then go to the report and find your new
entered event. If it does what it does on my computer you will notice
that for some reason the bar is in the wrong place. I'm guessing that
it has something to do with the math in the detail_Format section. The
report is perfect for what I need but if you put in an event in the
latter half of the timeline it doesn't seem to show correctly on the
chart. Any Ideas.
Thanks
Shawn Yates

Jul 19 '06 #3

P: n/a
Hi Shawn,

As a general rule you should avoid using 'On Error Resume Next'.
Anything could be happening in your code and you would not realise what
was going on (it also makes debugging easier as the code will stop
where the error occurs).

Good Luck

Nick

Shawn Yates wrote:
Oops I forgot to post the VBA code here is all of it:

Option Compare Database
Option Explicit

Private mdatEarliest As Date
Private mdatLatest As Date
Private mintDayDiff As Integer
------------------------------------------------------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

On Error Resume Next

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
Me.boxGrowForDate.Visible = True
Me.lblTotalDays.Visible = True
intStartDayDiff = Abs(DateDiff("d", Me.StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", Me.EndDate, Me.StartDate))

If intStartDayDiff = 0 Then intStartDayDiff = 1
With Me.boxGrowForDate
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor
End With
Me.lblTotalDays.Left = Me.boxGrowForDate.Left
Me.lblTotalDays.Caption = intDayDiff & " Day(s)"
Else '
Me.boxGrowForDate.Visible = False
Me.lblTotalDays.Visible = False
End If
End Sub
---------------------------------------------------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Min([Start Date]) AS MinOfStartDate
" _
& " FROM Projects", dbOpenSnapshot)
If rs.RecordCount 0 Then
mdatEarliest = rs!MinOfStartDate
End If
Set rs = db.OpenRecordset("SELECT Max(IIf(IsDate([End
Date]),CDate([End Date]),Null)) " _
& "AS MaxOfEndDate FROM Projects", dbOpenSnapshot)
If rs.RecordCount 0 Then
mdatLatest = rs!MaxOfEndDate
End If

mintDayDiff = DateDiff("d", mdatEarliest, mdatLatest)

Me.txtMinStartDate.Caption = Format(mdatEarliest, "mm/dd/yyyy")
Me.txtMaxEndDate.Caption = Format(mdatLatest, "mm/dd/yyyy")
Set rs = Nothing
Set db = Nothing
End Sub
Jul 19 '06 #4

P: n/a

Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
..Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
..Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?

Jul 19 '06 #5

P: n/a
I would write the procedure something like

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))

If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <= .boxMaxDays.Left +
..boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) .boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
..lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub

--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
>
Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?

Jul 19 '06 #6

P: n/a
I should have added:-

Do you see now how much code that On Error Resume Next had to be replaced
by, and I'm not guaranteeing that I got it exactly right.

My personal opinion on the "On Error Resume Next" construct is that it is
just another tool, so long as you understand what it is doing for you and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people it without thinking about it.
--

Terry Kreft
"Terry Kreft" <te*********@mps.co.ukwrote in message
news:ld********************@karoo.co.uk...
I would write the procedure something like

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))

If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <= .boxMaxDays.Left
+
.boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) >
..boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
.lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub

--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...

Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?


Jul 20 '06 #7

P: n/a
I should have added:-

Do you see now how much code that On Error Resume Next had to be replaced
by, and I'm not guaranteeing that I got it exactly right.

My personal opinion on the "On Error Resume Next" construct is that it is
just another tool, so long as you understand what it is doing for you and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people it without thinking about it.
--

Terry Kreft
"Terry Kreft" <te*********@mps.co.ukwrote in message
news:ld********************@karoo.co.uk...
I would write the procedure something like

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))

If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <= .boxMaxDays.Left
+
.boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) >
..boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
.lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub

--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...

Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?



Jul 20 '06 #8

P: n/a
For a fully working database, if you have an issue then the On Error
Resume Next gets round with out having to write reams of code then yes
it is just another tool. However if you are developing a database it
is and I think that you will agree a big no no. I feel that if you do
use it you should use it only for the lines of code that need it, then
turn the error handling on again.

Good Luck

Nick

Terry Kreft wrote:
I should have added:-

Do you see now how much code that On Error Resume Next had to be replaced
by, and I'm not guaranteeing that I got it exactly right.

My personal opinion on the "On Error Resume Next" construct is that it is
just another tool, so long as you understand what it is doing for you and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people it without thinking about it.
--

Terry Kreft
"Terry Kreft" <te*********@mps.co.ukwrote in message
news:ld********************@karoo.co.uk...
I would write the procedure something like

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))

If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <= .boxMaxDays.Left
+
.boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) >
.boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
.lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub

--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
>
Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?
>
Jul 20 '06 #9

P: n/a

Terry Kreft wrote:
I should have added:-

Do you see now how much code that On Error Resume Next had to be replaced
by, and I'm not guaranteeing that I got it exactly right.

My personal opinion on the "On Error Resume Next" construct is that it is
just another tool, so long as you understand what it is doing for you and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people it without thinking about it.
--

Terry Kreft
"Terry Kreft" <te*********@mps.co.ukwrote in message
news:ld********************@karoo.co.uk...
I would write the procedure something like

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single

Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff

If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))

If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <= .boxMaxDays.Left
+
.boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) >
.boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
.lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub

--

Terry Kreft
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
>
Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?
>
Jul 20 '06 #10

P: n/a
You seem to have missed this in my post so I'll say it again:-

"My personal opinion on the "On Error Resume Next" construct is that it is
just another tool, so long as you understand what it is doing for you and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people (use) it without thinking about it."

--

Terry Kreft
"Nick 'The Database Guy'" <ni*****@btinternet.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
For a fully working database, if you have an issue then the On Error
Resume Next gets round with out having to write reams of code then yes
it is just another tool. However if you are developing a database it
is and I think that you will agree a big no no. I feel that if you do
use it you should use it only for the lines of code that need it, then
turn the error handling on again.

Good Luck

Nick

Terry Kreft wrote:
I should have added:-

Do you see now how much code that On Error Resume Next had to be
replaced
by, and I'm not guaranteeing that I got it exactly right.

My personal opinion on the "On Error Resume Next" construct is that it
is
just another tool, so long as you understand what it is doing for you
and
what it is hiding from you then there is no reason to not use it, what
causes the problem is when people it without thinking about it.
--

Terry Kreft
"Terry Kreft" <te*********@mps.co.ukwrote in message
news:ld********************@karoo.co.uk...
I would write the procedure something like
>
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer
Dim intDayDiff As Integer
Dim sngFactor As Single
>
Me.ScaleMode = 1 'Twips
sngFactor = Me.boxMaxDays.Width / mintDayDiff
>
If Not IsNull(Me.StartDate) And Not IsNull(Me.EndDate) Then
With Me
intStartDayDiff = Abs(DateDiff("d", .StartDate, mdatEarliest))
intDayDiff = Abs(DateDiff("d", .EndDate, .StartDate))
>
If intStartDayDiff = 0 Then
intStartDayDiff = 1
End If
.boxGrowForDate.Left = .boxMaxDays.Left
.boxGrowForDate.Width = intDayDiff * sngFactor
.boxGrowForDate.Left = .boxMaxDays.Left + (intStartDayDiff *
sngFactor)
If (.boxGrowForDate.Left + .lblTotalDays.Width) <=
..boxMaxDays.Left
+
.boxMaxDays.Width Then
.lblTotalDays.Left = .boxGrowForDate.Left
ElseIf (.boxGrowForDate.Left + .lblTotalDays.Width) >
.boxMaxDays.Left
+ .boxMaxDays.Width Then
.lblTotalDays.Left = .boxMaxDays.Left + .boxMaxDays.Width -
.lblTotalDays.Width
Else
.lblTotalDays.Left = .boxMaxDays.Left
End If
.lblTotalDays.Caption = intDayDiff & " Day(s)"
.boxGrowForDate.Visible = True
.lblTotalDays.Visible = True
End With
Else '
With Me
.boxGrowForDate.Visible = False
.lblTotalDays.Visible = False
End With
End If
End Sub
>
>
>
--
>
Terry Kreft
>
>
"Shawn Yates" <sy****@cc.usu.eduwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...

Thanks Terry, I did this and it fixed the problem.
Should be
.Width = intDayDiff * sngFactor
.Left = Me.boxMaxDays.Left + (intStartDayDiff * sngFactor)
I also got rid of "On Error Resume Next" as Nick suggested but now I
have a new issue. When I put in an event that spans almost from the
beginnig to the end of my time line it displays error 2100 "The
control
or subform control is too large for this location" so I debug and
.Width = intDayDiff * sngFactor is highlighted. I put my cursor over
intDayDiff and sure enough it is the event that spans most of the
timeline. I checked:
sngFactor = Me.boxMaxTime.Width / mintTimeDiff
and I also checked
.Left = Me.boxMaxTime.Left + (intStartTimeDiff * sngFactor)
and this should easily fit without problem.
Next I went to the design view of my report and streache the page
way
out to see if it would fix the problem. Oddly enough the error 2100
didn't show up and now with a huge amount of space the event is
exactly
where it should be (it doesn't strech way outside the page like I
thought it might). Any ideas why this is happening or how to fix it?

>
>

Jul 20 '06 #11

P: n/a

Thanks a million guys you helped me greatly.
Shawn

Jul 20 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.