By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Command button press

P: 365
Hello again...

just a quicky (hopefully)

How do you set a command button's "special effect" to be sunk... using VB code.

i have 3 buttons that i want to "sink" the active button for the one that is active... like a toggle switch!

Dec 13 '07 #1
Share this Question
Share on Google+
6 Replies

P: 365
NM found it in the help file, i did look before i posted but i expected it to be...

Me!cmb1.specialeffect = .....
but it is
Forms("frmStaffHols").Controls("cmb1").SpecialEffe ct = 2
if it works!
Dec 13 '07 #2

P: 365
Ok it doesnt work for command buttons (everything else tho!!!)

so i still help from the pro's!!
Dec 13 '07 #3

Expert 2.5K+
P: 3,532
What do you mean by "want to sink the active button for the one that is active?" If you mean, by active button, the last one to be clicked, then this hack will come close:

At any rate, what you'd have to do is to use textboxes as faux command buttons. Textboxes have a click event just like a button, and so they can be used to execute code.

In the Property Box format each textbox initially to look like a "normal" button. You can select all three and format them at the same time:

Special Effect
Back color (you must have the minus sign in front of the number)
Control Source
= "My Fake Button Caption"
Text Align
Place a command button on the form, hit Cancel (it won't have code behind it because it doesn't do anything) and name it PhantomButton. Place it in the lefthand, bottom corner of your form, and shrink it as small as possible.

Then place this code behind the textboxes:
Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBox1_Click()
  2.  TextBox1.SpecialEffect = 2
  3.  TextBox2.SpecialEffect = 1
  4.  TextBox3.SpecialEffect = 1
  5.  'Place code to be executed here
  6.  PhantomButton.SetFocus
  7. End Sub 
  9. Private Sub TextBox2_Click()
  10.   TextBox1.SpecialEffect = 1
  11.   TextBox2.SpecialEffect = 2
  12.   TextBox3.SpecialEffect = 1
  13.   'Place code to be executed here
  14.   PhantonButton.SetFocus
  15.  End Sub 
  17. Private Sub TextBox3_Click()
  18.   TextBox1.SpecialEffect = 1
  19.   TextBox2.SpecialEffect = 1
  20.   TextBox3.SpecialEffect = 2
  21.   'Place code to be executed here
  22.   PhantonButton.SetFocus
  23.  End Sub
Placing focus on PhantonButton takes the cursor away from the textbox cum button,; otherwise the cursor would blink on the "button" and destroy the illusion!

Linq ;0)>
Dec 13 '07 #4

Expert Mod 15k+
P: 31,494
Ok it doesnt work for command buttons (everything else tho!!!)

so i still help from the pro's!!
Sunken; Raised; Flat; etc are sensible options for most controls.
As a button needs to use Sunken & Raised for its two different STATEs, it's not sensible to provide that option in its design. Does that make sense?
Dec 19 '07 #5

Expert 100+
P: 108
Another way you can do this is to make a Label control with the button text and set the style to raised. Then take a transparent command button and lay it over top of the label. From there all you would need do is alter the label's properties when the button was pressed.

This is a great way of having more control over your buttons than access allows. As far as the user knows the button looks like whatever the label is set to look like.

Hope this helps

- Minion -
Dec 19 '07 #6

P: 365
I am using a toggle switch now, thanks anyways

Dec 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.