what about providing a screenshot of your updated relevant blocks?
what about providing a screenshot of your updated relevant blocks?
these are all blocks... not only the relevant ones...
sorry, I do not have time to look at all the blocks... maybe @ABG does have more time...
Sorry, here you can see the relevants blocks of the problem. I formated the data as @ABG suggested, but when I press the btnCargar it compares the dates but make nothing until I mannually press do it
did you update diaSeleccionado in TinyDB with the correct data format?
in the screenshot you might want to add a Do it result for diaSeleccionado and hoy...
also the better method for comparing dates are the Duration methods from the clock component, which can return a positive or negative value Sensors
Returns the milliseconds by which end follows start (+ or -)
I did update it. Now I deleted every entry. Let me do it again and I will show you. Thanks for your suggestion about the time. I will try to introduce it in the block. But for now the problem is that even though the comparison of the selected day in the tinydb altough it exists, it does not retrieve the contents as it does the app when I select the button Recuperar datos
Here it is
But in the screen I am still seeing the data of the last data (of day 2022-05-03)
When rellenarDatos is called, I do not get the data corresponding to the selected day (that should be 111, 222, and 333 for datos 1, 2 and 3, respectively)
Sorry, I only know English, so I would be lost trying to guess what is what.
@ABG: Here I am uploading the aia with al variables and staff names in english. I you can look at it, It will be of great help for me. I am stuck with it and cannot go further. Please pay attention to the procedure in btnLoadData. The routine do nothing except opening the date picker. If you Retrieve any data and then want to load another already loaded day, you will see that neither cleanTbx nor the fillingData subroutines will respond. Thank you so much in advance
Datos_copy.aia (10.8 KB)
ok, which means, the Do it result shows the correct valuess...
if you are testing, you have to execute the Do it results in the correct sequence
probably it makes more sense to
set global datos inside the rellenoDeDatos procedure at the beginning...
I see a problem in the save data button click event.
You don't take into account the data you had previously saved for a day:
This is how it should be for that problem:
I suggest fixing the saving of data before trying to debug loading of data that is not there.
Further thought ...
I see in your work a problem similar to another users' work that I saw within the last day or so.
He had two versions of the truth, a global variable and a TinyDB value.
They were causing confusion.
I advised getting rid of the global variable, and using only the TinyDB value.
Here is a sample app that uses TinyDB without any global variables ...
Thanks @TAIFUN and @ABG for your suggestions, but unfortunately neither of the 2 options worked for me. I think the problem is not in the TinyDB but in the btnLoadData procedure (previously btnCargar). When I load data after looking up information through btnRetrieveData (previously btnRecuperar), regardless of whether I load a date that had previous data, as if I was creating a new one, the data in the textboxes does not disappear, even when a refresh call is made through the cleanTbx subroutine. If that subroutine worked, no previous data should be seen (although the call to TinyDB would fail afterwards). It seems to me that the problem is in the very call of the btnLoadData button, as if there is a computer conflict when following the sequential events. Obviously, it is far beyond my reach to solve it. Note that the ListPk_Data.AfterPicking routine does practically the same thing as Loading Data (retrieves data from a TinyDB and fills the textboxes with the fillingData subroutine) and there is no problem displaying the results there.
Datos_copy.aia (11.4 KB)
In the competition for worst variable name, the name 'list' has long held the championship.
Now we have a new champion, 'data'.
(At least the name 'datos' might possibly be the name of a small island off the Greek coast populated by a tribe of Amazon women coders.)
What's wrong with such names, you ask?
Those names are useless in helping to distinguish among the possible types, purposes, quantities, and meanings of whatever such variables hold.
Your 'data' variable holds a table of some sort, with rows containing 2 columns, the first colun is some useless attribute name, and the second column is the value of that attribute.
You are doing nested selects, and I am not convinced you are using the right indices for each select at each level.
This is a case where local variables, well named, would help make clear what is happening.
Local variables can act as stepping stones in your fast moving stream of thought.
Without them, it is too easy to get swept under and drown in confusion.
Before I can attempt to understand your code, I would need to see:
- a descriptive variable name for the collection of records in the variable formerly known as 'data', like 'cheeses'
- a local variable for the currently selected row in the previous item in this list, like 'current_cheese'
- a local variable name for column 1 of the current row, like 'cheese_attribute_name' (country?)
- a local variable name for column 2 of the current row, like 'cheese_attribute_value' (France?)
@ABG, here I am going again. I changed the variable names and routines to be more descriptive. I tried to declare a local variable to retrieve te values stored at the TinyDB and probably did something wrong because now I cannot store any value. I hope you have enough patience to give me a hand to try to solve the problem. I still think that it is not a problem of storing the values but of the flow of the program in btnLoadValues.
Datos_copy.aia (12.1 KB)
I loaded your project, did a Clean Up Blocks, and immediately saw
It reminds me of a movie I once saw, about a man doomed by a brain disease to wake up each morning without any knowledge of the past, and his wife's attempts to meet him for the first time every day.
That TinyDB.ClearAll block should be buried deep in a Setup menu, with a DANGER warning.
It has no business in a Screen1.Initialize event.
I think I saw a similar movie with Adam Sandler and Drew Barrymore.
The clearall of the TinyDB I just put it there when dibugging, to reset the possible tags remaining in the base, but ones deleted I disabled it.
After going around the process several times (many hours) and not being able to solve the problem, I decided to create 2 separate subroutines. One to create new records and anotherone to edit previously loaded records. Holy remedy.
The problem was in the fillingData subroutine (probably because of the name). When calling findDay the correct day was recorded, but in the loop, the local variable dateValues recorded the previous record, whether it was previously displayed or loaded. When the same day was loaded again, it brought the correct values.
By separating the load subroutine from the edit subroutine the problems gone (but just the app problems).
Thank you for the suggestion about not declaring a global variable for loading the TinyDB registers. I found them difficult to debug, but makes the task easier. Cheers