I have been trying to update calculated fields and apply this to all records rather than going through each record and manually "hitting" Calculate button for that specific record.
so i ahve used varies methods to cycle through records the current is as follows:
Code:
Public Sub LoopRecExample()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Income/Expense") 'open the recordset for use (table, Query, SQL Statement)
With rs
If .RecordCount <> 0 Then 'Ensure that there are actually records to work with
'The next 2 line will determine the number of returned records
rs.MoveLast 'This is required otherwise you may not get the right count
rs.MoveFirst
Do While Not .EOF
'Do something with the recordset/Your Code Goes Here
Debug.Print rs.Fields("amount")
Call TaxCalculation
.MoveNext
Loop
End If
End With
rs.Close 'Close the recordset
Error_Handler_Exit:
On Error Resume Next
'Cleanup after ourselves
Set rs = Nothing
Set db = Nothing
Exit Sub
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: LoopRecExample" & vbCrLf & "Error Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
the debug.print works it does display the correct figures, but the call function/subroutine didn't work. I am clearly missing something with the loop communicating with the subroutine (TaxCalculation).
Can anyone either help or focus me to some reading material would be greatly appreciated.