Moving text between Windows Text Areas

I have 2 Windows with a text area field on each (WinMain and winCreationStepEvents). Using the TextChange Event, I would like to make the text content the same in both fields. This works great from WinMain to the 2nd Window, but not from the 2nd Window to WinMain. There I get the error that this This Item does not exist, even when including the WinMain path in the code. Why is this?

Works:
This is the code I use to copy from the WinMain Window to the winCreationStepEvents Window, placed in the text field on the WinMain Window:
winCreationStepEvents.textStep1CreationStepEvent.text = me.Text

Does not work:
This is the code I use to copy from the winCreationStepEvents Window to the WinMain Window, placed in the text field on the winCreationStepEvents Window:
WinMain.txtStoryCreationStepOne.text = me.Text

The errors I get:
WinCreationStepEvents.textStep1CreationStepEvent.TextChange, line 1
Static reference to instance method: call this on an instance of class WinMain.WinMain.
WinMain.txtStoryCreationStepOne.text = me.Text

WinCreationStepEvents.textStep1CreationStepEvent.TextChange, line 1
This item does not exist
WinMain.txtStoryCreationStepOne.text = me.Text

Me Refers to the Control the code is in…

Adapt your code to:


Window1.TextArea1.Text = Window2.TextArea1.Text

Window2.TextArea1.Text = Window1.TextArea1.Text

I tried that,
WinMain.txtStoryCreationStepOne.text = WinCreationStepEvents.textStep1CreationStepEvent.Text

but it gives the same Item does not Exist error.

My guess is that the controls have a private scope (check the Inspector) which means you cannot access them from outside.

If that is the problem you can resolve this by changing the scope to public. Personally, I would leave the scope as private and have a public method with a parameter on the receiving window that updates the control text.

All objects are set to Public already. However, I will leave it this way. It’s not a big problem because the text field on the 2nd smaller Window is for reference only and I can set it to Read Only. Thanks.

typo error ?

How do you instantiate WinMain ?

If you have implicit instance, winmain should be recognized.

If you use a variable to instantiate the window, you need to use a property instead, which you will address as prefix to the TextArea.

txtStory… or textStory… ?