Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically change the state of Toggle Button

Status
Not open for further replies.

tkordick

Programmer
Dec 1, 2001
10
0
0
US
I have an form where user presses (turns on) a toggle button then does some work in the form. Based on the work they do, I want to programmatically change the state of the toggle button to off. I call the toggle buttons click event which calls the logic but the button still displays as depressed. How do I change the appearance so it does not appear pressed?

Thanks
 
Hi tkordick,

Toggle buttons are either "true" or "false". "True" is shown as depressed. "False" is raised.

In your code, after the user does what ever your trigger is, set the toggle to "false".

sub test_afterupdate()

me!toggle0 = false

end sub

I hope I understand what you are asking. If I didnt answer it, post back with a little more specifics and I will try again.

HTH Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Hello,
Version: Access 97

Luckily I found a thread about this issue already. I too need to change the state of the toggle button automatically.

Specifically, I have a form with two toggles in an option group. When the form is opened, I want toggle1 to be defaulted to "pressed".

I tried:

me!toggle1 = True

But I get an error stating:

"You can't assign a value to this object"
* The Object may be a control on a read only form.
* The object may be on a form that is open in Design view.
* The value may be too large for this field.

Any ideas??
 
Ordendelfai

If you've got controls within an option group then u need to set the value of the option group rather than the individual control within it.

eg

optiongroupname = "Blue" will toggle the blue on and the red off

hth

H

Hany Mustapha
Excellent Technology Solutions in the UK -
 
Hi Hany,

That pointed me in the right direction, thank you much :)

I used the below code and it worked:

Private Sub Form_Load()
Me!OptionGroup = 1
End Sub

("1" was the value of the option group, not the name).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top