Toggle Buttons...Help Needed with coding!!...PLEASE!

hey yer barred

Board Regular
Joined
Jun 19, 2007
Messages
232
Hi All!

I have never used toggle buttons before so this is probaly why they aint working!

Just so I can get used to them, Ive created 3 simple toggle buttons called Call Centre, Team Manager and Agent.

Which ever one is active, and you click on a button called 'Test'...it will display a message box saying Call Centre.
e.g - if Team Manager is toggled, and test is clicked, Team Manager will appear in a message box..

Heres my coding

Dim togag As New Control
Dim togcc As New Control
Dim togtm As New Control

If Me.togag.Value = True Then
MsgBox "Agent"
ElseIf togcc.Value = True Then
MsgBox "Call Centre"
ElseIf togtm.Value = True Then
MsgBox "Team Manager"
Else
MsgBox "Nothing Selected!"
End If

End Sub


Any ideas why its not working?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
instead of declaring = True replace it with 1 and check for the result

Regards
Ranjit
 
Upvote 0
Call Centre, Team Manager and Agent
This is what you said you "called" each of the three toggle buttons. But in your code you "called" them "togag", "togcc", "togtm". Access has no idea what you are refering to in your code. You need to use the actual name you gave those 3 buttons on your form. The Dim statements you used in your code don't tell Access anything about the toggle buttons on your form.
And, by the way, True is the correct thing to use in this case. "1" is not True, "-1" is True.
 
Upvote 0
Are these toggle buttons inside of an Option box?

Why have you done this:
Code:
Dim togag As New Control 
Dim togcc As New Control 
Dim togtm As New Control
I would think that if you take these three lines out, it would help. Also, I never use .Value when dealing with a control on a form.
 
Upvote 0
I'm really sorry, but I thought I had sent you yesterday the same stuff that is in this post, but I see it never got to the forum. :-(
Toggle buttons work the same way as Option buttons and Check boxes when inside of an Option Box. So, what you will need to do is to use the Option Value property in each of the Toggle Buttons. Make togAc = 1, togCC = 2, and togTM = 3. Then in the code, you will need to reference the option box within the If/If Else/End If logic.
Code:
If Me.OptionBox = 1 Then 
  MsgBox "Agent" 
ElseIf Me.OptionBox = 2 Then 
  MsgBox "Call Centre" 
ElseIf Me.OptionBox = 3 Then 
  MsgBox "Team Manager" 
Else 
  MsgBox "Nothing Selected!" 
End If
 
Upvote 0

Forum statistics

Threads
1,222,102
Messages
6,163,933
Members
451,866
Latest member
cradd64

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top