J
Jeff G
Hello all-
I have set up a function listed below. What I'm trying to do is:
1. Select the expenseGLVoucherNumber in the tblExpenseIntegrationGLAccount
table.
2. Assign the expenseGLDistributionSequenctNumber via VBA.
Example:
Voucher expenseGLDistribtuionSequence
expenseCreditAmount expenseDebitAmount
300000001 16384
50 0
300000001
0 25
300000001
0 25
Here's the code:
Function UpdateDistributionSequenceNumber()
Dim RecordCount As Integer
Dim RecordCount2 As Integer
Dim db As Database
Dim rec As DAO.Recordset
Dim rec2 As DAO.Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select expenseGLVoucherNumber from
tblExpenseIntegrationGLAccount Where expenseGLDistributionSequence is Null")
rec.MoveFirst
RecordCount = 0
Do Until rec.EOF
Set rec2 = db.OpenRecordset("SELECT * from
tblExpenseIntegrationGLAccount WHERE expenseGLVoucher=" & rec)
rec2.MoveFirst
RecordCount2 = 0
Do Until rec2.EOF
rec2.Edit
rec2!expenseGLDistributionSequence =
DMax("expenseGLDistributionSequence", "tbltblExpenseIntegrationGLAccount") +
16384
rec2.Update
RecordCount2 = RecordCount2 + 1
rec2.MoveNext
Loop
rec.MoveNext
Loop
End Function
When I run the code, I receive an error:
Run-time error '2766': The object doesn't cont the Automation object '|.'
I'm pretty sure that the error is somewhere in the nested loop.
Any help would be much appreciated.
Thanks in advance.
Jeff
I have set up a function listed below. What I'm trying to do is:
1. Select the expenseGLVoucherNumber in the tblExpenseIntegrationGLAccount
table.
2. Assign the expenseGLDistributionSequenctNumber via VBA.
Example:
Voucher expenseGLDistribtuionSequence
expenseCreditAmount expenseDebitAmount
300000001 16384
50 0
300000001
0 25
300000001
0 25
Here's the code:
Function UpdateDistributionSequenceNumber()
Dim RecordCount As Integer
Dim RecordCount2 As Integer
Dim db As Database
Dim rec As DAO.Recordset
Dim rec2 As DAO.Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select expenseGLVoucherNumber from
tblExpenseIntegrationGLAccount Where expenseGLDistributionSequence is Null")
rec.MoveFirst
RecordCount = 0
Do Until rec.EOF
Set rec2 = db.OpenRecordset("SELECT * from
tblExpenseIntegrationGLAccount WHERE expenseGLVoucher=" & rec)
rec2.MoveFirst
RecordCount2 = 0
Do Until rec2.EOF
rec2.Edit
rec2!expenseGLDistributionSequence =
DMax("expenseGLDistributionSequence", "tbltblExpenseIntegrationGLAccount") +
16384
rec2.Update
RecordCount2 = RecordCount2 + 1
rec2.MoveNext
Loop
rec.MoveNext
Loop
End Function
When I run the code, I receive an error:
Run-time error '2766': The object doesn't cont the Automation object '|.'
I'm pretty sure that the error is somewhere in the nested loop.
Any help would be much appreciated.
Thanks in advance.
Jeff