So this must be an easy task, but i feel I have a blind spot here…
I am using the same text field a couple of times in the desktop app I am building. And I would like to see the same text that is being filled in at all the text fields. So if the user makes a change in one field, that change must show up in the other fields as well.
I tried to grasp the .text value of the field in a variable and to set the .text value of the other fields with this variable, but this doesn’t work. How can I make this happen?
Thanks. The project doesn’t run, it gives an error. But I came around the same it by using a Button to send the info to all the text fields:
txtConcept2.value = txtConcept.Value etc
A solution I could also think of is that when the field receives a return key, it could run this same script. I believe this is how it worked in Filemaker which I used for many years. I recently picked up Xojo again, so I am little rusty…
You don’t need an intermediate variable to do this.
Double-click the textfield and add an Event Handler for “TextChanged”
Inside that event, set all the other fields’ .Text property to txtConcept.text
Every time your textfield is changed by the user, the other textfields will now update.
If you’d like to use a variable to do it, the problem you might be running into is that based on the place that you declare the variable, it goes out of scope by the time you want to use it. To get around that, add a property of type String to your window, and store the value in that property instead of a variable local to a particular event handler.
That explains it… the project I uploaded to Dropbox is 2022r2 (API 2.0). If you want, just to learn how, you can download the latest release from Xojo: Downloads
thanks. I am still a starter in Xojo so things cannot be too complicated, otherwise I have no idea what I am doing. I solved it by placing a button next to every text field which then updates all the other text fields with this code:
I found an even easier way to get what I want by using the LostFocus Event handler on the text fields which then run the script to change the other text fields. I also noticed that hitting the return key does the same, so I don’t even need the buttons.