Help with TinyDB

Hi

Second post on here from a noob! I have made an app that I want a field(Running Balance) to remain when the app is closed. I've kinda managed it but it doesn't quite work as expected.
What I want to happen is when I open it I can then subtract a figure from the called Running Balance but when I do the first figure is added not subtracted, it seems to recall another figure that I stored the first time, not the one I closed with last time. It works for the next figure to be subtracted.
Here are my blocks - be kind I've only been doing this for 24 hours and I'm in my late 60s so not an up-to-date spring chicken!

What is Stored.Text? Use a text block and a constant value as tag, for example the text balance
70 is always your start value? Then valueIfTagNotThere should be 70
Store the value of the balance after each transaction, i e. In event Log_Spend
Running balance and opening balance always is equal? To have only one balance would be sufficient then

Running Balance = Running Balance - Spend

Taifun

Hi Taifun, not sure if this resolves my issue, let me give you some more information.

The app is to track weekly spending budget. I start the week with £70 and then subtract what I spend during the week to make sure I don't overspend (I'm a pensioner).

So when I hit reset button the running balance should reset to £70. If I then spend £5 and hit log the running balance reduces to £65. Before, if I closed the app the running balance would reset.

What I want it to do is remember the running balance of £65 when I close and reopen it, then if I spend another £3 it goes to £62 in the running balance and so forth until I hit reset when it will go back to £70 for the start of the second week.
Here is the design -

Hope you can help?

Rex

See my previous answer and if this still does not help, then provide a screenshot of your updated blocks

Taifun

Sorry, I'm not clever enough to understand your answer.

Thanks anyway.

Use a text block and a constant value as tag, for example the text balance

valueIfTagNotThere should be 70

Store the value of the balance after each transaction, i e. In event Log_Spend

To have only one balance is sufficient

Running Balance.Text = Running Balance.Text - Spend.Text

Taifun

WOW! Thank You this works perfectly.

I don't really follow the logic as I'm getting a bit to old and learning doesn't come as quick.....good job I'm only doing this as a bit of fun.

Rex

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.