J
Joanne
Hello, I have a subform in Access 2003 with these fields, type of day,
OLPEndDate, OLPBeginDate. At the end of each row, I want to calculate the
total day taken for that particular vacation request, so if a person took
12/1/2009-12/2/2009 then the last field "TotalOLPTaken" should calculate as
1. What's happening is that it does calculate but all of the rows calculate
to the same number. If I put the cursor in the second row and that row
happens to have 12/4/2009-12/6/2009, then even the row with 12/1-12/2
calculates as 2. Then if I put the cursor back in the first row, everything
calculates as 1. I realize I have the even on "Got Focus" but I've tried it
with every possible trigger and it always calculates the same way. Any help
would be appreciated.
Private Sub txtTotalOLPTaken_GotFocus()
Dim dTaken
Dim dStart
Dim dEnd
dEnd = Me.OLP_End_Date1.Value
dStart = Me.OLP_Begin_Date1.Value
If Me.Type_of_Day.Value = "Ill" Or Me.Type_of_Day.Value = "Vacation" Then
dTaken = DateDiff("d", dStart, dEnd)
MsgBox dStart & " " & dEnd
Me.txtTotalOLPTaken.Value = dTaken
End If
End Sub
OLPEndDate, OLPBeginDate. At the end of each row, I want to calculate the
total day taken for that particular vacation request, so if a person took
12/1/2009-12/2/2009 then the last field "TotalOLPTaken" should calculate as
1. What's happening is that it does calculate but all of the rows calculate
to the same number. If I put the cursor in the second row and that row
happens to have 12/4/2009-12/6/2009, then even the row with 12/1-12/2
calculates as 2. Then if I put the cursor back in the first row, everything
calculates as 1. I realize I have the even on "Got Focus" but I've tried it
with every possible trigger and it always calculates the same way. Any help
would be appreciated.
Private Sub txtTotalOLPTaken_GotFocus()
Dim dTaken
Dim dStart
Dim dEnd
dEnd = Me.OLP_End_Date1.Value
dStart = Me.OLP_Begin_Date1.Value
If Me.Type_of_Day.Value = "Ill" Or Me.Type_of_Day.Value = "Vacation" Then
dTaken = DateDiff("d", dStart, dEnd)
MsgBox dStart & " " & dEnd
Me.txtTotalOLPTaken.Value = dTaken
End If
End Sub