Any Suggestions on 438 or 2100 errors

P

Plumdodge

Hi,
This report tracks employees project plans and pulls in the "current" week
from a query. Any suggestion or glaring mistakes?

Option Compare Database
Option Explicit

Private mdatEarliest As Date ' Monday of the current Week'
Private mdatLatest As Date ' Saturday of the current week'
Private mintDayDiff As Integer ' Number of Days between the two is 5'

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intStartDayDiff As Integer 'Number of Days From Current Monday'
Dim intDayDiff As Integer 'Days From Start to End Date this week'
Dim sngFactor As Single 'Scale Factor of layout'
Dim WorkHours As Double 'The estimated number of hours invovled'
Dim dblchk As Long


On Error GoTo Ert ''If something bombs out drop it and move on''

dblchk = (Me.boxGrowForDate.left + Me.boxGrowForDate.Width)

'' My attempt to see what the problem is''
Me.Text66 = dblchk

'' Twips - 1440 in 1 inch or 567 in 1 centimeter'
Me.ScaleMode = 1

'' Number of estimated hours
WorkHours = Me.Estimated_Hours_for_task

''Width of bar at the top of report divided by Number of Days between Mon &
Sat (5)''
sngFactor = Me.boxMaxDays.Width / mintDayDiff

'' If both start and stop dates are filled out then fire it up''
If Not IsNull(Me.T_Start_Date) And Not IsNull(Me.T_Stop_Date) Then
'' Show the colored bar''
Me.boxGrowForDate.Visible = True
'' Show the number of days ''
Me.lblTotalDays.Visible = True

''Number of Days From Current Monday''
''Figure the difference between ( the greater of the start date or Monday of
this week minus monday of the current week''
intStartDayDiff = Abs(DateDiff("d", IIf(Me.T_Start_Date < mdatEarliest,
mdatEarliest, Me.T_Start_Date), mdatEarliest))
''Days From Start to End Date this week'
''Figure the difference between ( the stop date if it fails this week or
Saturday of this week minus saturday of the current week''
intDayDiff = Abs(DateDiff("d", IIf(Me.T_Stop_Date + 1 > mdatLatest,
mdatLatest, Me.T_Stop_Date + 1), IIf(Me.T_Start_Date < mdatEarliest,
mdatEarliest, Me.T_Start_Date)))


'' Set the color bar width to the number of days in the task and place it
relative to placement bar
'' at the top of the report ''
With Me.boxGrowForDate
.left = Me.boxMaxDays.left + (intStartDayDiff * sngFactor)
.Width = intDayDiff * sngFactor
End With
'' Say the number of days calculated and place it with the colored bar''
Me.lblTotalDays.left = Me.boxGrowForDate.left
Me.lblTotalDays.Caption = WorkHours & " Hour(s)"



Me.txtMinStartDate.Width = sngFactor
Me.day2.left = Me.boxMaxDays.left + sngFactor
Me.day2.Width = sngFactor
Me.Day3.left = Me.boxMaxDays.left + (sngFactor * 2)
Me.Day3.Width = sngFactor
Me.day4.left = Me.boxMaxDays.left + (sngFactor * 3)
Me.day4.Width = sngFactor
Me.day4.txtMaxEndDate.left = Me.boxMaxDays.left + (sngFactor * 4)
Me.txtMaxEndDate.Width = sngFactor

''If either the start or stop date is blank then do nothing''
Else
Me.boxGrowForDate.Visible = False
Me.lblTotalDays.Visible = False
End If


Dent:
Exit Sub

Ert:
MsgBox "Error number " & err.Number & ": " & err.Description
Resume Dent

End Sub

Private Sub Report_Open(Cancel As Integer)


'Set Start Date to Monday of this week
mdatEarliest = Date - Weekday(Date, vbMonday) + 1

'Set End Date to Saturday of this week
mdatLatest = Date - Weekday(Date, vbSaturday) + 8

'Get Scale Set to 5 for weekly report
mintDayDiff = DateDiff("d", mdatEarliest, mdatLatest)

'Slap some values on the labels
Me.txtMinStartDate.Caption = Format(mdatEarliest, "mm/dd/yyyy")

Me.day2.Caption = Format(mdatEarliest + 1, "mm/dd/yyyy")

Me.Day3.Caption = Format(mdatEarliest + 2, "mm/dd/yyyy")

Me.day4.Caption = Format(mdatEarliest + 3, "mm/dd/yyyy")

Me.txtMaxEndDate.Caption = Format(mdatLatest - 1, "mm/dd/yyyy")

End Sub
 

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