How do you get data entered to remain visible after screen change?

I have a google sheet form for the app I am building. I have been able to get all the data to copy over to the sheet when ever the user presses the buttons. However if the user changes screen (which i want them to be able to do) all the entered data disappears from the screen (not the sheet).

How do I get all the data to stay on the screen until the user click a reset button or something?


I can't see the image , too little and low resolution.
If you change screen the data are delete and you have to fill again the form . So you have to save data in a tinyDb for example and fill on initialize screen . But if you use arrangement like a screen you don't lost data. You.can set visible true or not the arrangements to simulate the switch of the screen.

I am very new to this program so it is all alerning curve.
Have added the AIA if this helps.
I have no idea what your solution is, but any guidance you can give would be appreciated.

RankWatch.aia (139.2 KB)

I edit my first answer . Now I'm not at pc so I can't manage your aia. Probably using arrangements to simulate screens could be a solution . Or wait for another solution by an user more expert than me.

1 Like

I am using a number of arrangements with in the screen. So not sure how this would maintain any of the entered data. I have also changed it to a single "Submit" button so it writes all data to the Google Sheet.

Hopefully someone can help. I appreciate you looking at it anyway.

1 Like

Of course. But you have to use one over the other , like a container that can simulate a screen . So if you set not visible this arrangement you can hide all . If you don't change screen and don't work on this components when they are hided they will be the same when you show them again . I can see a lot of work in this form so wait before try my hint :muscle:t2:

Hello Chris

The cause of the issue is brought about by how you switch screens.

Looking at the Screen 'Form', 'Open another Screen' is used to open Screen 'Menu'.

However, in Screen Menu there is 'Open another Screen' to open Screen 'Form'.
What that is doing is literally opening another Screen 'Form', so now there are two of them in allocated memory and the latest, empty one you just opened is the one displayed. That accumulation in memory will eventually make the App crash.

Issue

If instead you do this:

Snap2

The User will be taken back to the Screen that launched the current Screen, i.e. Screen 'Menu'.

It's a pity we didn't hear from you earlier because we would have recommended using Virtual Screens instead - they are all in the same memory allocation and so the data is retained:

When we define virtual screens, we use one 'real' App Inventor Screen (most often Screen1). Screen-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual Screens. This is generally a better approach for multi-screen Apps, they share data without having to "pass" it between screens and it also reduces code duplication, making the App more efficient and the code easier to follow if you have to return to it at a later date.
So, instead of separate "houses", virtual screens are "rooms" of the same "house".

Deleted

Also, I note that you are defining components such as Buttons in Pixels. Smartphones are in various sizes and screen resolutions, so what may look good on your phone may be not-so-good on others. Use percent sizing instead.

ButtonSize

ProfessorCad: Tips & Tricks GUI Layout

So, you have two choices:

  1. Keep the current Screens. On leaving a Screen save it's data to TinyDb, ready to be restored if that Screen is opened again. Edit: Actually, since you save the data in a spreadsheet, you could read the data from that when the Screen 'Form' is opened again.

  2. Change your design to use Virtual Screens - which is what Raffaele is trying to describe.

1 Like

Since you keep a strict one to one correspondence between your Form Screen textboxes and spreadsheet cells, it should be possible to reload the Form screen from the current sheet, by asking for the entire sheet, turning the Comma Separated Values (CSV) response into a table (list of lists), and load each Textbox.Text from its corresponding row and column in that table.

2 Likes

Another thing Chris - via your 'Write' button on Screen 'Form', you have a succession of Spreadsheet Cell Writes - given that the spreadsheet is in the Cloud, doing it that way is risking reliability. There is a 'FinishedWriteCell' Block which should be used.

Here is an example of how to use 'FinishedWriteCell' (Not tested!)

RankWatch_ScreenFormBlocksEdit.aia (140.0 KB)

2 Likes

This AIA doesn't work, but hopefully this will point me in the right direction..

Thanks, now I know the right name :sweat_smile:

1 Like
1 Like

That array of cell names and Textbox components would come in handy for mapping CSV table contents to the display when a full sheet arrives.

1 Like

Hi Chris (nice name by the way)

Tell me precisely what the problem is and I should be able to fix it.

Try this one - Note, only Screen 'Form' has been edited, to use FinishedWriteCell

RankWatch_ScreenFormBlocksEdit2.aia (140.1 KB)

Awesome name Chris...
I took into account what you were saying about virtual screens, and I have created the attached. but now it will not write to sheet. HELP please.
RankData.aia (132.5 KB)

You are missing a Spreadsheet Error event block and a Notifier component to announce any errors.

Drag this block into your Blocks WorkSpace, and pull in a Notifier.

If you get an error message testing, show it to us.