Jump to content
Sign in to follow this  
CCBtx

GetNthRecord Result does not Calculate correctly

Recommended Posts

Arrrgggggg. I love these undocumented features! !!!

I have four fields.

Period = (1-60 months)

BeginningBalance = GetNthRecord ( EndingBalance ;Get( RecordNumber)-1 )

Credits = Say, 100

EndingBalance = BeginningBalance + Credits

So, Here are the Records

Period...BegBal........Credits..........EndBal

1...............0.................100..............100

2............100................100..............200

3............200................100..............300

4............300................100..............400

....and so on (the dots are spaces)

It calculates perfectly in the root table.

However, I have another table that is indexed to the first table using Period as the relationship

When I try to access EndingBalance from a form using the second table, I get....

Period EndBal

1 100

2 100

3 100

4 100

....it ignores the BegBalance (and I did not make a mistake and reference Credits).

If I take out the GetNthRecord calculation and hard code the number, it works just fine.

I suppose I could start at the first record and step through the found set calculating the Beginning Balance from the ending balance of the last record... but that seems to defeat GetNthRecord.

Has anyone seen this before? Help! :hmm:

Share this post


Link to post
Share on other sites

It seems to be calculating as I would expect it to...

I think BeginningBalance field would have to be an unstored calculation since it uses GetNthRecord function - which means it's re-evaluated every time it is referenced. Then, GetNthRecord is context-dependent, which means if you change the found set, or the sort order, it will evaluate differently and that is effectively what you are doing when you are referencing the field from a related table.

I'm not quite sure what your goal is, but another method you could try would be to use a summary field defined to keep a running total.

Share this post


Link to post
Share on other sites

I would probably experiment more... but my FM12Adv client locks up when I change the calculation.

..summary field. Execellent suggestion. Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.