I know understand your issue.
What you are doing:
You open an instance of Form1 with a repeating panel. You want to set the Table
variable to be set to which ever number is clicked on Form1.
You then want Form2 to open and have access to that Number that was selected.
The Problem:
You are setting the Table variable to a local variable only available within the method button_1_click
in the repeating panel of Form1.
This means that variable is only available within the scope of that method. As soon as you exit that method, the variable no longer exist. Even within Form1 or the repeating panel itself.
How can you fix it?
There are multiple ways you can fix it.
I would say you should spend some time reading up on classes, methods, and scope. This will help you understand how to get these two forms to communicate and is the core issue. It will also prevent you from repeating this mistake and save a lot of headache (I have definitely given myself too much headache by not reading up enough).
Either way, I don’t wanna leave you without some solution to this specific issue so here it is:
I would create a parent form , lets call it “Base” where you can set class variables that will live outside the scope of your methods. Then you can open your Form1/ Form2 in your “Base” form as components. To do this you can drag them onto the form or add them to the form via code using <column panel component>.add_component(Form1())
. From there, you can figure out how to set the class variables of the “Base” when ever a repeating panel row is clicked.
Clone to get you started:
https://anvil.works/build#clone:FUCXN4ZKE3UKLLCV=5FLLDVRTHJCNKHK2PSHGPYJ3
It is far from perfect or complete, but I wanted too give you an idea of what I was talking about.
hint: I would use a publisher to publish when a component is clicked to and pick that up in your base form. anvil extras is a great dependency you can add to your code to make your life easier and has the publisher library. here is a link to that:
All the instructions on how to use it can be found in the documentation or even by searching in this forum.
Cheers!