Simple referencing, I think!

just an idea but you could try using

rst.Fields("[Field]").value

instead of

rst![Field]

or it could be

rst.Fields("Field").value

not cirtain if you need the [] or not.


Another idea if you want to remove "/"'s from your field names use sql like this

sql = "Select [C/F] as CF, EELoan, Profit, NetProfit, Tax from test"

now the [C/F] field is just CF. :D
 
YOU R A LEGEND

yeah am talkin about you Shadez

just as I thought there was no hope, nice all is clear in world Access now, until the next problem

this seemed to work a treat:

Cal1 = rst.Fields("[C/F]").Value + rst!EELoan - rst!Profit

CHeers for all that help

Case CLosed

~ SOLVED ~:D
 
No probs m8


:cool:ShadeZ:cool:
 
While it is acceptable to do this sort of thing in code, you shouldn't be doing it to a recordset opened by a form. Use a recordset created specifically for the process. In any event, a query is almost always quicker and should require much less debugging. I included the Nz() functions because the calculations will not work if any of the fields contain null values.

query1:
Select YourKeyfields, [C/F], EELoan, Profit, [BalanceC/F],
IIf(Nz([C/F],0) + Nz(EELoan,0) - Nz(Profit,0)) <> Nz([BalanceC/F],0), "Error1", Null) As Err1, NetProfit, Tax, Profit, IIf(Nz(NetProfit,0) - Nz(Tax,0) <> Nz(Profit,0), "Error2", Null) As Err2
From YourTable;
query2:
Select * from query1 where Err1 Is Not Null or Err2 Is Not Null;

When you run query2, you'll get back only rows with one of the two error types.

I hope you learned 2 things from this exercise.
1. Never store calculated values.
2. Never use embedded spaces or special characters in your object names.

PS, the recordset will be updatable so you can correct the errors or you could simply run a query that recalculates everything rather than just checking for errors.
 

Users who are viewing this thread

Back
Top Bottom