Calculate between recordsets on Form

I am getting a warning that the expression entered has a function containing the wrong number of arguments

G: IsNull(DLookup("E", "Table1", "B = " & Table1. & " AND A = " & Table1.[A] - 1), "")

Apologies for being a pain, but I cannot see what the problem is as it now looks so perfectly logical....:confused:
 
Isnull has no second argument:

G: IsNull(DLookup("E", "Table1", "B = " & Table1. & " AND A = " & Table1.[A] - 1))

There however is a much easier way to do this ! (sorry for joining the thread so late...)

This 'simply' is a join !!!! but then a bit different...

Code:
SELECT Table1.a, Table1.b, Table1_1.a, Table1_1.b
FROM Table1 INNER JOIN Table1 AS Table1_1 ON Table1.b = Table1_1.b AND Table1.a = (Table1_1.a-1);

Something like that....
You should be able to calculate to your harts content after addapting above... (and get much better performance than using Dlookup)

Regards

Regards
 
Looks like you are building a new table, table1_1 from table1

SELECT Table1.A, Table1.B, Table1.F, Table1_1.A, Table1_1.B, Table1_1.E
FROM Table1 INNER JOIN Table1 AS Table1_1 ON Table1.B = Table1_1.B AND Table1.A = (Table1_1.A-1) AND …!!;

Will the JOIN query handle this problem..(see example statement below) I have rewritten the problem below…

A…… B…. … C……D…….E…… F…………...........G
2001…1…….2……40……80…………………………
2002…1…….3……30……90……110……(110-8)=102
2003…1…….2……60……120…..115……(115-9)=106
2001…2…….5……40……200…………………………
2002…2…….3……50……150…..110……(110-20)=90
2003…2…….4……60……240…..115……(115-15)=100


‘A’ along with ‘B’ are unique identifiers for a particular record and this is what helps identify a current and previous record (‘A’ being the year and ‘B’ a field which we can follow through from year to year).

‘E’ is a calculated field that multiplies ‘C’ and ‘D’

‘F’ is determined from autolookup tables

‘G’ is a calculated field that takes 10% of ‘E’ from previous record and subtracts from current record in ‘F’


‘G’ is the value I wish to calculate using a query/expression

Example written statement is:

Want field ‘B’=2 and Current year ‘A’ = 2003, where calculated ‘F’ = 115.
Previous year ‘A’= ‘A’-1 = 2002, want same field ‘B’ = ‘B-1’ = 2 and calculated ‘E’ = ‘E’-1 = 150
The expression/query wants to put result in field ‘G’ = ‘F’ – ‘E-1’(10%) with respect to ‘A’&’B’

....A......B.....F......A-1....B-1....E-1
G = (2003 2 115) - (2002 2 15)


This problem just does not seem to want to go away

Cheers
 
Try attached A97 format DB. I took your above sample, put it into a table (YourTable) and took my query (from above as well) and did the calculations as you wanted them...

*Handing it to you on a silver platter*
-With a Cogney accent- *here you are Sir*

Regards

The Mailman
 

Attachments

Wow...that is great, I am indebted to you Namliam. Looks like I need to turn to queries to solve my problems. Recommend any good books?

Thank you also dcx692 and Pat Hartman for your contributions.

Regards
 

Users who are viewing this thread

Back
Top Bottom