Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
I am producing a time sheet whihc can be printed. I have solved what is needed on the form for calculations but the report is proving to be a little annoying:

I am using the same code as the form and ths calls to a global variable in a module. It all works well on the form but the report does not calculate the first value but does the others and totals the 5 day week, missing out the Monday. The problem appears to be 'MondayTotal' which is called as a global variable from a module.

My code for Monday is:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim timHours As Date
'calculates the MonAM time in minutes... Uses the Global Variable [MondayAM]
timHours = Me.Mon1 - Me.Mon2
MondayAM = Hour(timHours) * 60
MondayAM = MondayAM + Minute(timHours)
'will loop around each time and then to the ending calculations
Call Mon3_AfterUpdate

End Sub

Private Sub Mon3_AfterUpdate()

Dim timHours As Date
Dim MondayTotal As Integer

'calculates the MonPM time in minutes... Uses the Global Variable [MondayPM]
timHours = Me.Mon3 - Me.Mon4
MondayPM = Hour(timHours) * 60
MondayPM = MondayPM + Minute(timHours)
'the minutes for the day added up together
MondayTotal = MondayAM + MondayPM
Me.MonTotal = Int(MondayTotal / 60) & " : " & (MondayTotal Mod 60)
'will loop around each time and then to the ending calculations
Call Tues1_AfterUpdate

End Sub

After going through the days of the week (Mon-Fri) in exactly the same fashion it then comes to this code which totals all of the total variables:

Sub WeeklyMinuteCount()

Dim MinuteTotals As Integer

'count up the minutes for the week
MinuteTotals = MondayTotal + TuesdayTotal + WednesdayTotal + ThursdayTotal + FridayTotal
'converts the weekly minutes into hours and minutes
Me.WeeklyTotal = Int(MinuteTotals / 60) & " : " & (MinuteTotals Mod 60)
End Sub

It all seems okay so why isn't this variable being used correclty? I'm totally confused... ;o/

Thanks for any suggestions....
 
What a fool... the answer is usually the most obvious thing but always never crosses your mind when you're in a panic. I left the Dim in so it couldn't send to the Global variable in the module:

Private Sub Mon3_AfterUpdate()

Dim timHours As Date

Dim MondayTotal As Integer '#This was the problem#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top