How do I move text from a a detail field to a button label?

Oracle Forms - 10g

I have a working form with a standard header/detail one to many relationship. (Up to 4 detail lines are displayed at any one time.)

I would like to add push buttons to the detail section, displaying (in the label) text from another column from the details table. (After I'll do something when the button is pushed, but I won't worry about that now.)

I have been able to add a Text Item to the details and display the data from the new column there, but I want to be able to see this data on the push buttons. I assume I need to do one of the following:

A. Get the data to appear directly on the push buttons the way I can using the Display Item item.
B. Automatically copy the text from the Display Item fields to my push buttons.

Attached you will find a screen capture which I hope helps in the understanding of my problem.

Thank you.

Who is Participating?
jwahlConnect With a Mentor Commented:
this will not work in this way: with SET_ITEM_PROPERTY you can set the labels only fpr ALL buttons (records) in the block ... and SET_ITEM_INSTANCE_PROPERTY doesn't support this also.

i think you have to do a workaround: change the buttons to unbound fields and give them visual attributes, so that they look like buttons.

in the POST-QUERY-trigger of your the detail block (D20RE) put

:D20RE.my_button_item := :d20re.tdnb_text;

to fire the "button", create a trigger code in WHEN-NEW-ITEM-INSTANCE ...
Why do you need a push button there ? you can't simply populate data of a text item into a push button.
caldernetAuthor Commented:
I am planning on having a push button open an associated attachment.
For now, I would like to simply populate data of a text item (TDNB_TEXT) into the label of my push button (TDNB_PUSH_BUTTON) but I simply don't know how to do it.

The following may be close but it gives me an error

While :system.Last_Record <> 'TRUE' LOOP
    set_item_property(':d20re.TDNB_PUSH_BUTTON', label, :d20re.TDNB_TEXT);
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

caldernetAuthor Commented:
_____ I put the following in the detail block's POST-QUERY trigger and it appears to do NOTHING.___
_____ It compiles OK ______________________________--

aa varchar(128);
while :system.last_record = 'False' loop
  aa := :d20re.tdnb_text;
  set_item_property('tdnb_push_button', label, aa);
end loop;
MarkusIdConnect With a Mentor Commented:
The Problem is, that you can't set the label of a button per instance, only for all buttons at one.

However, you may have a look at this link, it's probably what you want to do, but only with text instead of the icons.
caldernetAuthor Commented:
For the moment, I'm testing jwahl's solution as it appears simpler. However...

- Should the trigger not be WHEN-MOUSE-CLICK, rather than WHEN-NEW-ITEM-INSTANCE (which fires when the fields are loaded) ?
- How do I make these fields "unbound" ? What would this accomplish?
- Right now pressing ENTER when my new "button" has focus tabs me to the next could make ENTER = mouse click ?

jwahlConnect With a Mentor Commented:
> Should the trigger not be WHEN-MOUSE-CLICK, rather than WHEN-NEW-
> ITEM-INSTANCE (which fires when the fields are loaded) ?

you may be right. didn't test it ;-)

> How do I make these fields "unbound" ? What would this accomplish?

sorry, should better say "no base table item" (properties: Database Item = No)

> Right now pressing ENTER when my new "button" has focus tabs me to the next could make ENTER = mouse click?

try KEY-NEXT-ITEM (field level) trigger and put your code there ...
MarkusIdConnect With a Mentor Commented:
Yes, I also think that the WHEN-MOUSE-CLICK-trigger is more useful in this case.

Maybe jwahl means with unbound that it is not attached to a database field.

KEY-NEXT-ITEM-trigger should catch the ENTER. You only have to make a call to the WHEN-MOUSE-CLICK-trigger there.
caldernetAuthor Commented:
Thanks - I assume I still want to be Database Item = Yes, as I like the fact that the text on my "button" shows the data from the database automatically.

Please let me know why you think I might want to disconnect this field from database.

(I imagine I'll be assigning points for this question shortly.)
you have to set Database Item = Yes only if you want the data of the field to be stored in the database!
but in your case it's only a display item -  so set database item=no ...
caldernetAuthor Commented:
When I set Database Item = No, I no longer see the contents of the field on the "button", so I'm setting it back to "Yes".

Setting Update Allowed = No will prevent anybody from changing the contents of this column.


Bruce C.
caldernetAuthor Commented:
Actually, my button was set to "Text Item" - So I changed it to "Display Item" (so "Update Allowed" is no longer a parameter.)

I still have to have it set to Database Item = Yes or the text will not display.
Curiously, I have another Display Item with the Datatase Item set to No which does display that column's data.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.