Dears
Could anybody assist me in solving this problem.
I am trying to update a table replacing the content of a field with the
summation of the relevant succeeding fields.
The content of the field used in controlling the summation is "Detail" or
"General".
If it is General, all the succeeding records that contain "Details" in the
type field should have their totals sum into the preeceeding General field.
The replacement work fine except for the first record and one other record
within the file.
The code is as shown below.
Function UpdtIncExp()
Dim tot As Single, numCk As String, I As Integer
Dim dbs As Database, rstAccts As Recordset
Set dbs = CurrentDb
Set rstAccts = dbs.OpenRecordset("Accounts Master", dbOpenTable)
tot = 0
numCk = " "
rstAccts.MoveLast
Do Until rstAccts.BOF
If rstAccts!Type = "Detail" Then
tot = tot + rstAccts!Total
numCk = rstAccts![Account Code]
ElseIf rstAccts!Type = "General" Then
rstAccts.Edit
rstAccts!Total = tot
rstAccts.Update
numCk = " "
tot = 0
End If
rstAccts.MovePrevious
Loop
rstAccts.Close
End Function
I need urgent help p l e a s e!
-----------------------------
-Ajao
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com