473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What is wrong with this VBA code?

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
11 3270

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
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
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

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
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
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
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
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

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
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

Thanks a million guys you helped me greatly.
Shawn

Jul 20 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
1
by: GS | last post by:
I got a combobox box that I load at load time. the Item and vales ended up in reverse order of each other, what went wrong? the database table has the following row code value ebay ...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
20
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.