R
Rotsey
Hi,
I am writing a function to update a number of tables under transaction
control.
One of the updates fail on the rsEmp.Update statement.
When I run the same function without transaction control it runs fine.
The code where it fails is labelled below.
Does anyone know of reasons why updates do fail under transactions.????
rotsey
gSQL = "SELECT PayFrequency,TempPayFrequency FROM Employees WHERE
EmployeeID = " & !EmployeeID
If Not GetODBCRecordset(gSQL, rsEmp) Then GoTo ErrExit
If Not rsEmp.BOF Then
If Not IsBlank(rsEmp!PayFrequency) Then
If Left$(rsEmp!PayFrequency, 3) = "Non" Then
PayFreqType = "Non"
Else
PayFreqType = "Res"
End If
gSQL = "SELECT * FROM PayFrequency WHERE PayFrequencyCode =
'" & rsEmp!PayFrequency & "' "
If Not GetODBCRecordset(gSQL, rsPay) Then GoTo ErrExit
If Not rsPay.BOF Then
If (CInt(!WeeksInvoiced) = 2 And rsEmp!PayFrequency =
"resHalfMonthly") Or (CInt(!WeeksInvoiced) = 2 And rsEmp!PayFrequency =
"NonResHalfMonthly") Then
' Do Nothing
ElseIf CInt(rsPay!NumWeeksInPeriod) <>
CInt(!WeeksInvoiced) Then
gSQL = "SELECT * FROM PayFrequency WHERE
Substring(PayFrequencyCode,1,3) = '" & PayFreqType & "' "
gSQL = gSQL & " AND NumWeeksInPeriod = " &
!WeeksInvoiced
If Not GetODBCRecordset(gSQL, rsPay) Then GoTo
ErrExit
If rsPay.BOF Then
MsgBox "Error: Weeks Invoiced does not exist in
PayFrequency table for employee " & EmpName & " Rolling back process.",
vbCritical, "Temp Pay Frequency"
CreateSalaryInvoice = False
GoTo ErrExit
Else
rsEmp.Edit
rsEmp!TempPayFrequency = rsPay!PayFrequencyCode
MsgBox ("Step E6 " & rsPay!PayFrequencyCode)
rsEmp.Update 'THE UPDATE FAILS HERE
MsgBox ("Step E7")
End If
End If
End If
I am writing a function to update a number of tables under transaction
control.
One of the updates fail on the rsEmp.Update statement.
When I run the same function without transaction control it runs fine.
The code where it fails is labelled below.
Does anyone know of reasons why updates do fail under transactions.????
rotsey
gSQL = "SELECT PayFrequency,TempPayFrequency FROM Employees WHERE
EmployeeID = " & !EmployeeID
If Not GetODBCRecordset(gSQL, rsEmp) Then GoTo ErrExit
If Not rsEmp.BOF Then
If Not IsBlank(rsEmp!PayFrequency) Then
If Left$(rsEmp!PayFrequency, 3) = "Non" Then
PayFreqType = "Non"
Else
PayFreqType = "Res"
End If
gSQL = "SELECT * FROM PayFrequency WHERE PayFrequencyCode =
'" & rsEmp!PayFrequency & "' "
If Not GetODBCRecordset(gSQL, rsPay) Then GoTo ErrExit
If Not rsPay.BOF Then
If (CInt(!WeeksInvoiced) = 2 And rsEmp!PayFrequency =
"resHalfMonthly") Or (CInt(!WeeksInvoiced) = 2 And rsEmp!PayFrequency =
"NonResHalfMonthly") Then
' Do Nothing
ElseIf CInt(rsPay!NumWeeksInPeriod) <>
CInt(!WeeksInvoiced) Then
gSQL = "SELECT * FROM PayFrequency WHERE
Substring(PayFrequencyCode,1,3) = '" & PayFreqType & "' "
gSQL = gSQL & " AND NumWeeksInPeriod = " &
!WeeksInvoiced
If Not GetODBCRecordset(gSQL, rsPay) Then GoTo
ErrExit
If rsPay.BOF Then
MsgBox "Error: Weeks Invoiced does not exist in
PayFrequency table for employee " & EmpName & " Rolling back process.",
vbCritical, "Temp Pay Frequency"
CreateSalaryInvoice = False
GoTo ErrExit
Else
rsEmp.Edit
rsEmp!TempPayFrequency = rsPay!PayFrequencyCode
MsgBox ("Step E6 " & rsPay!PayFrequencyCode)
rsEmp.Update 'THE UPDATE FAILS HERE
MsgBox ("Step E7")
End If
End If
End If