Button procedure to place text in a text object


I have a gardening database. The green window shows the plant details. The checklist on the side shows all of the gardens that contain that plant. A given type of plant can be in multiple gardens. The gray window allows me to select records for a specific garden. A button for each garden. The procedure for the current button selection is: select Garden contains "Center”, so the records I can view are the plants that are in the Center Hill Garden.

I want to have a text object on the Plant Detail form that shows which selected set I am currently viewing. So I’m thinking that the button procedure could be:

select Garden contains “XYZ”
Put “XYZ” into text object on the form Plant Detail - (Would replace text already shown in the text object ) - I don’t know how to write this procedure. Searched but can’t figure out how to do this.

Any help is appreciated.

neonate, it sounds like you are asking for two different things. First you are asking to see which selected set you are viewing - so that’s just a display.

I don’t know what you mean by “set” but if each garden had a field that contained its “set” designation, you could just add that field to your form.

In the next paragraph, you are asking for something else. You are asking to display your selection criteria on a form. So again, that’s just a display. But when you ask how to write the procedure, It sounds like you also want to know how to write a selection procedure and then display the criteria you used on the form.

So where to start? Are you saying your selection of desirable records is working and the only problem is displaying the criteria used?

1 Like

A text display object can be set to display the result of a formula, or literal text. Normally, you would use it to display a formula, and this is the default setting when you create a new one. In your case, the simplest formula would just be a FileGlobal variable containing the text you want to display. Let’s name our variable ChosenGarden.

You would begin by creating a procedure with the exact name of .Initialize

This procedure will run automatically when the database opens, and you will use it to declare the variable and give it an initial (empty) value.

letfileglobal ChosenGarden = ""

In the Formula pane for your object, you would enter the variable name ChosenGarden

image

Then the button procedure could be

select Garden contains "Center"
ChosenGarden = "Center"
ShowVariables ChosenGarden

The ShowVariables command at the end will cause every object with that variable in its formula to be updated. Without it, the object would just continue to show the previous value.

1 Like

@Dave This is exactly what I wanted to do. Thank you.

@designer Thanks for your response. I’m sorry if my question was unclear.
By “set” I meant the currently selected records. The example above shows that I’m currently viewing the 6 plants that are in the Hill Garden-East. The text box on the Plant Detail Form will now show me the current records that I am viewing (Will format this text box appropriately, later).

I may have additional questions but I want to try to figure out some things on my own.

Again, thanks to all.