Different button label on lines of continuous form

F

Fjordur

Hi,
I have a continuous form. Each record contains a field that I use to display
the label of a button that belongs to the detail section and triggers a
specific macro (whose name is in another field). If the field is empty I
don't display the button at all.
This I do with a macro that sets properties of the button. This macro is
called in the "OnCurrent" event of the form.
The problem is, all records have the same button (displayed or hidden) with
the same label; each time I click on a record the label changes according to
the clicked record; it changes in all records at the same time.
I would like to have the button display the proper, diffrent, label for each
record.

Any ideas?
 
A

Allen Browne

Only a bound control can display a different value on every row of a
continuous form or datasheet.

The Caption of a button cannot be bound to a control, so it follows that you
cannot take that approach.

You could set up your button with no caption, and then add a text box with a
transparent background in front of your command button (Format menu in form
design.) In the GotFocus event of the text box, execute the code in the
command's Click event:
Call Command1_Click()
 
F

Fjordur

Allen Browne said:
Only a bound control can display a different value on every row of a
continuous form or datasheet.

The Caption of a button cannot be bound to a control, so it follows that you
cannot take that approach.

You could set up your button with no caption, and then add a text box with a
transparent background in front of your command button (Format menu in form
design.) In the GotFocus event of the text box, execute the code in the
command's Click event:
Call Command1_Click()
Hmmm... I don't understand what it is you call Command1, is that the
button's name?

Could I just have a text field "macroLabel", locked, that would call a macro
by its name stored in another text field "macroName"?
 
A

Allen Browne

Sure. You don't need the command button (which was assumed to be Command1 in
the example.)

You could set the text box's Locked property to Yes, and fire off a macro in
a suitable event, such as Enter or GotFocus.

You probably want to set its TabStop property to No so it only gets focus by
clicking on it, not by tabbing through the controls on the form.
 
F

Fjordur

Fjordur said:

Got the idea. My final (hopefully :) solution is as follows:
I have a field "macroLabel" on each record, plus a macro for the OnCurrent
event of the form, that sets the OnClick event of the "macroLabel" field to
the field "macroName". A bit of conditional formatting to make the
"macroLabel" field look a little bit like a button et voila...
Thanks to all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top