简体   繁体   中英

How to create a calculated field that calls the same calculated field in MS ACCESS

I am creating a Access database query from an excel spreedsheet where the row "Total Capital Calls" is calculated by itself and "Current Capital Call", which is static.

The data from the spreedsheet:

                                 A          B           C           D  

1 Current Capital Call 1,000,000 240,000 2,000,000 1,960,000

2 Total Capital Calls 1,000,000 1,240,000 3,240,000 5,200,000

The calculation is as follows:

                                 A          B           C           D      

1 Current Capital Call 1,000,000 240,000 2,000,000 1,960,000

2 Total Capital Calls 1,000,000 =+B1+A2 =+C1+B2 =+D1+C2

So the formula is repeated as data moves to the next Total Capital Call field, summing the total to the next 'Total Capital Call' field.

I am trying to create a calculated field in a query using the same calculated field name in the calculation. I need the calculated field "Total Capital Calls" to sum itself with the field [Current Capital Call].

For example:

SELECT LlamadoDeCapital.[Total Capital Committed], 
    LlamadoDeCapital.[Capital Call Request Date], 
    LlamadoDeCapital.[Capital Call Date], 
    LlamadoDeCapital.[Current Capital Call], 
    [Current Capital Call]+[Total Capital Calls] 
AS [Total Capital Calls]
FROM LlamadoDeCapital;

After running the query, I get this message:

Circular reference caused by alias 'Total Capital Calls' in query definition's SELECT list

Is it possible to call the calculated field in it's own expression??

or

Is there better solution to summing the calculated field with itself and the other field?

Ok, so adding the clng function was the resolution:

DSum("CurrentCapitalCall","LlamadoDeCapital","CapitalCallDate <=" & clng( [CapitalCallDate] ) ) AS TotalCapitalCalls

Running Sum total with both fields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM