Full Version: Command Button and related label
UtterAccess Forums > Microsoft® Access > Access Forms
jnisbett
I have seen (and used) switchboard forms which contain command buttons, where the button's function is contained in an adjacent label. The button responds with a color change when I mouseover either the button or the label, and the button's function occurs whether I click the button or the label.
How do I connect the label with the button so that they act as a single unit?
J
Jack Cowley
Call the Command buttons code with the On Click event of the label:
all CommandButtonName_Click()
Be sure you get your syntax correct...
hth,
Jack
strive4peace
Hi J,
You cannot "attach" a label to a command button

What you do, however, is assign the Click event of the label to run the code on the Click event of the command button

you can use the MouseMove event to change the back color of the command button
Me.commandButton_controlname.BackColor = 10092543 'yellow
(Hello Jack!)
jnisbett
Thanks Jack. Your suggestion will add the button's functionality to the label, but I still can't get the mouseover effect.
jnisbett
Hi Crystal,
How that suggestion sounds like a winner. I can't wait to try it!
Thanks.
J
jnisbett
Crystal & Jack,
When I look at a form that displays may desired effect in design view and focus on the command button, the label highlights also, just like an option button. Somehow the command button and label are connected, but don't see how in the design.
J
Jack Cowley
Hiya Crystal!
Always a happy moment when I see your smiling countenance...
Jack
strive4peace
Hello Jack,
It is always nice to see you too wink.gif
strive4peace
Hi J,
ost the database and specify what to look at, we will take a look and see what is set up
Jack Cowley
Aw shucks, Crystal blush.gif
jnisbett
Here's the form in question...
strive4peace
Hi J,

I do not see any of the cool stuff you described in the database that you posted ...
jnisbett
Oh. I see it at my end.
I use over the descriptions, and see if the adjacent button highlights. (Access 2003)
J
strive4peace
Hi J,

no, it does not ... look at the db you posted, not your working db...
jnisbett
Crystal,
checked the attachment, and it worked for me.
Otook and attached screenshots:
- Notice the highlighted button on the 4th option - obtained when I mousedover the label.
- Notice the button and label seem to be related in design view.
Thanks for your help.
Now my wife's calling... Gotta go
Thanks for your advice.
J
LPurvis
At a guess - I'd suggest you're mistaking the subtle focus (dotted) effect on a command button for colour changing.
(You can't change the background colour of command buttons in a standard fashion).
Which explains why Crystal couldn't see any such effect - it'll be Windows theme dependent).
HAs for attaching a label to a command button - you can do this, and do so in the same way you attach any control as the parent of a given label (manually through Design view that is).
Once the label already exists select it - Cut it - select the command button to be its parent - and Paste.
As I say - just as you would for a data control... but for a command button too.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.