Your blocks in Buttin2.click very complicated and duplicated - Alert bunch, bunch of action, some obscure check for null.
In programming, there is a recommendation - in every function you should try to perform only one operation, because the more complex the function, the much more difficult to look at her mistakes. Throw bugs Thukable X and will be very difficult to understand where your mistakes, and where the system error. For this reason, as variables I use function blocks and parameters only in case of emergency use global variables.
Create a simple function check, create a new row to be accurate or not.
If the database is recorded null, it means that the stored-block is not initialized (it nothing was written) or for whatever reasons, null is written in it. Blocks of global variables become unstable and I would not be surprised if it’s a bug system. For this reason, as variables I use function blocks parameters and only in case of emergency use global variables.