T
Tom Brophy
I'm having some problems and need help. The line below executes 1 time for
each detail line (creating distribution lines) - there are currently always 3
detail lines.
If PostDistribution(lngPostedTransaction, lngPostedDetail, TmpDetailID) Then
The first detail line goes through the following function correctly. The
second time, I get the run-tim 3146 ODBC call failed when it tries to open
RSDistr.
Anybody have any ideas?
Thanks,
Tom
Function PostDistribution(lngTran As Long, lngDetail As Long, lngTmpDetailID
As Long) As Boolean
Dim db As DAO.Database
Dim RSDistr As DAO.Recordset
Dim RSTmp As DAO.Recordset
Dim strSQLDistrTmp As String
Dim strSQLDistr As String
Dim blnTransOpen As Boolean
Dim strSQL As String
On Error GoTo Err_PostDistribution
On Error GoTo 0
'DBEngine.BeginTrans
blnTransOpen = True
strSQLDistr = "SELECT * FROM tblBTransDistr"
Set db = CurrentDb
Set RSDistr = db.OpenRecordset(strSQLDistr, dbOpenDynaset, dbSeeChanges)
'*** cycle through distribution ***
strSQLDistrTmp = "SELECT * FROM tblBTransDistr_tmp" '** WHERE
fknTransactionDetail_tmpID = " & lngTmpDetailID ' & ";"
Set RSTmp = db.OpenRecordset(strSQLDistrTmp, dbOpenDynaset, dbSeeChanges)
With RSDistr
Do Until RSTmp.EOF
If RSTmp.Fields("fknTransactionDetail_tmpID") = lngTmpDetailID
Then
.AddNew
.Fields("fknTransDetailID") = lngDetail
.Fields("fknTransactionID") = lngTran
.Fields("dtPost") = Date
.Fields("ChargeAmount") = RSTmp.Fields("ChargeAmount")
.Fields("ChargeInvAmount") =
RSTmp.Fields("ChargeInvAmount")
.Fields("TIGClaim") = RSTmp.Fields("TIGClaim")
.Fields("RMBillID") = RSTmp.Fields("RMBillID")
.Fields("dtDOL") = RSTmp.Fields("dtDOL")
.Fields("TranCode") = RSTmp.Fields("TranCode")
.Fields("PmtCode") = RSTmp.Fields("PmtCode")
.Fields("ExpenseCode") = RSTmp.Fields("ExpenseCode")
.Fields("BalanceAmount") = RSTmp.Fields("ChargeAmount")
.Fields("AppliedAmount") = 0
.Fields("TotPmt") = 0
.Update
End If
RSTmp.MoveNext
Loop
End With
RSTmp.Close
RSDistr.Close
Set RSTmp = Nothing
Set RSDistr = Nothing
'DBEngine.CommitTrans
blnTransOpen = False
PostDistribution = True
Exit Function
Err_PostDistribution:
If blnTransOpen Then
' DBEngine.Rollback
'cn.RollbackTrans
MsgBox Err.Number & ": " & Err.Description, vbCritical, "Rollback
Notification"
Else
MsgBox Err.Number & ": " & Err.Description, , Me.Name & " - " &
"PostDistribution"
End If
PostDistribution = False
End Function
each detail line (creating distribution lines) - there are currently always 3
detail lines.
If PostDistribution(lngPostedTransaction, lngPostedDetail, TmpDetailID) Then
The first detail line goes through the following function correctly. The
second time, I get the run-tim 3146 ODBC call failed when it tries to open
RSDistr.
Anybody have any ideas?
Thanks,
Tom
Function PostDistribution(lngTran As Long, lngDetail As Long, lngTmpDetailID
As Long) As Boolean
Dim db As DAO.Database
Dim RSDistr As DAO.Recordset
Dim RSTmp As DAO.Recordset
Dim strSQLDistrTmp As String
Dim strSQLDistr As String
Dim blnTransOpen As Boolean
Dim strSQL As String
On Error GoTo Err_PostDistribution
On Error GoTo 0
'DBEngine.BeginTrans
blnTransOpen = True
strSQLDistr = "SELECT * FROM tblBTransDistr"
Set db = CurrentDb
Set RSDistr = db.OpenRecordset(strSQLDistr, dbOpenDynaset, dbSeeChanges)
'*** cycle through distribution ***
strSQLDistrTmp = "SELECT * FROM tblBTransDistr_tmp" '** WHERE
fknTransactionDetail_tmpID = " & lngTmpDetailID ' & ";"
Set RSTmp = db.OpenRecordset(strSQLDistrTmp, dbOpenDynaset, dbSeeChanges)
With RSDistr
Do Until RSTmp.EOF
If RSTmp.Fields("fknTransactionDetail_tmpID") = lngTmpDetailID
Then
.AddNew
.Fields("fknTransDetailID") = lngDetail
.Fields("fknTransactionID") = lngTran
.Fields("dtPost") = Date
.Fields("ChargeAmount") = RSTmp.Fields("ChargeAmount")
.Fields("ChargeInvAmount") =
RSTmp.Fields("ChargeInvAmount")
.Fields("TIGClaim") = RSTmp.Fields("TIGClaim")
.Fields("RMBillID") = RSTmp.Fields("RMBillID")
.Fields("dtDOL") = RSTmp.Fields("dtDOL")
.Fields("TranCode") = RSTmp.Fields("TranCode")
.Fields("PmtCode") = RSTmp.Fields("PmtCode")
.Fields("ExpenseCode") = RSTmp.Fields("ExpenseCode")
.Fields("BalanceAmount") = RSTmp.Fields("ChargeAmount")
.Fields("AppliedAmount") = 0
.Fields("TotPmt") = 0
.Update
End If
RSTmp.MoveNext
Loop
End With
RSTmp.Close
RSDistr.Close
Set RSTmp = Nothing
Set RSDistr = Nothing
'DBEngine.CommitTrans
blnTransOpen = False
PostDistribution = True
Exit Function
Err_PostDistribution:
If blnTransOpen Then
' DBEngine.Rollback
'cn.RollbackTrans
MsgBox Err.Number & ": " & Err.Description, vbCritical, "Rollback
Notification"
Else
MsgBox Err.Number & ": " & Err.Description, , Me.Name & " - " &
"PostDistribution"
End If
PostDistribution = False
End Function