G
Guest
I have a form to record annual leave
1) Beginning balance (2)no. days to
take (3) end balance
(1) Begin balance is sourced from Master Leave table
(2) No. days to take is form input
(3) end balance is (1)-(2), and will update back to Master table
I wrote the following code but not work. Would appreciate any expert advice
and many thanks in advance
****************************************************
Dim fx1 As adodb.Recordset 'from master leave table
Dim t As Variant ' caculate leave balance
Set fx1 = New adodb.Recordset
fx1.Open "TbMasterLeave", CurrentProject.Connection, adOpenStatic,
adLockOptimistic
Do While Not fx1.EOF
If fx1("EmployeeID") = Forms!FmTempLeave!EmployeeID Then
fx1("AnnualEntitled") = t
Me!AnnualEntitled = fx1("AnnualEntitled")
t = fx1("LeaveBal")
Me!CumLeave = t
t = t - Me!LeaveTaken
Me!LeaveBal = t
End If
fx1.MoveNext
Loop
![Frown :( :(](/styles/default/custom/smilies/frown.gif)
take (3) end balance
(1) Begin balance is sourced from Master Leave table
(2) No. days to take is form input
(3) end balance is (1)-(2), and will update back to Master table
I wrote the following code but not work. Would appreciate any expert advice
and many thanks in advance
****************************************************
Dim fx1 As adodb.Recordset 'from master leave table
Dim t As Variant ' caculate leave balance
Set fx1 = New adodb.Recordset
fx1.Open "TbMasterLeave", CurrentProject.Connection, adOpenStatic,
adLockOptimistic
Do While Not fx1.EOF
If fx1("EmployeeID") = Forms!FmTempLeave!EmployeeID Then
fx1("AnnualEntitled") = t
Me!AnnualEntitled = fx1("AnnualEntitled")
t = fx1("LeaveBal")
Me!CumLeave = t
t = t - Me!LeaveTaken
Me!LeaveBal = t
End If
fx1.MoveNext
Loop