Dynamic Command Button Captions

GUIDO22

Registered User.
Local time
Today, 21:18
Joined
Nov 2, 2003
Messages
515
I would like to display a continuous form with a command button whose caption is dynamic; such that the button text is determined by a field in the underlying recordset of the table.

So, if the field were forename : each button caption maybe : Brian, Peter, Sally etc.

Is this possible / and how can it be done?

Thank you.
G
 
Try this...

Code:
Private Sub Form_Current()
    Me.Recalc
    Me.Button_Name.Caption = Me.FieldName ' text field that you want the text appear

End Sub


Le
 
No this is no good - I'm afraid

This code updates ALL of the command buttons to use the same text string each time the user moves to a new record!

My form displays all outstanding order items - each command button on the CONTINUOUS form needs to display the appropriate order number. eg.
I need to label the button as the form loads/displays with each individual order number.
 
I think you will have better luck using a TextBox and playing with the properties and events to get it to look and act like a CommandButton.
 
RG :
I have tried this also - although I am able to get the captions required on the buttons (textboxes!), I am trying to keep the mousepointer as the default cursor when the mouse moves over the textbox - (at present it turns to the text caret). Am I able to use the X,Y params of TextBox_Mousemove() event to specify the area enclosed by the text box to change the cursor?

Also, I am trying to simulate the button press action - changing the button effect from raised to sunken on the mousedown event and back again on mouseup. Only problem is : all the buttons follow suit!
Am I able to identify the record row the user has clicked in the Form_Current() event and from this row ascertain which of the textbox controls has been actioned?

I guess ultimately I could just have a blank button with a text label next to it (which I have elsewhere on my appl.)- but this would be a nice feature to have - if only I could fathom it out....
 
I hadn't thought of all of that, sorry. One of the many problems with continuous forms. They have good points too and I use them all of the time but there are some limitations on creativity. Have you tried a transparent TextBox on top of a command button?
 
I hadn't thought of all of that, sorry. One of the many problems with continuous forms. They have good points too and I use them all of the time but there are some limitations on creativity. Have you tried a transparent TextBox on top of a command button?
 
Great idea!

But when I overlay the transparent text box on the button - (even with Locked=True /Enabled=False / TabStop = Off), the operation of the button is inhibited. Only the extremities of the button can be 'pressed'. Furthermore, the text disappears when you do actually manage to press the button - the text does restore itself though - when focus moves to another record on the form.......
 
Darn! Thought I had something there. I guess you have to go with your plan B. Sorry. :(
 
I hadn't thought of all of that, sorry. One of the many problems with continuous forms. They have good points too and I use them all of the time but there are some limitations on creativity. Have you tried a transparent TextBox on top of a command button?

I was looking for something similar but was not sure how to make it work. Then I happened upon this post and tried the same thing but with the text box behind the button and I made the button transparent and the text box background colour set to "System Button Face".

Works like a charm! :)
 

Users who are viewing this thread

Back
Top Bottom