need help with togglebutton

G

Gary Keramidas

i have a command button that imports data and creates a chart. it always
creates the chart by rows.
i also have a togglebutton that changes the source to columns and then back
to rows.

the problem is, if the last selection was by columns, and i click the report
button, the chart comes in by rows, but the toggle button is clicked,
nothing happens because it is already in the source by row mode. i need to
click the button twice to reset it.

i need to select the toggle button from the command button code and reset
it's state. that way, every time the report is generated, the toggle button
will be in the original state, sort by column when it's clicked.

can someone hlep me out please?
 
G

Guest

Try putting this in your code that generates the chart:

Me.tglTest = False

Assumes the code running is on the same sheet as the toggle button. If not,
you will have to specify the sheet rather than use me. False will unselect
the toggle button and True will select it. The tglTest is just the name I
gave my test toggle button.

Let me know if you still have issues.
 
G

Gary Keramidas

scott:

what do i use for the Me variable? i don't know how to address the
togglebutton, and yes it's on the same sheet as the code.
 
G

Guest

Me is a reference to the current sheet, not a variable. When you type "Me."
you will see all of the controls on the sheet by name. Select the name of
the toggle button. You can even leave Me out if you like. I use it because
it makes it easier that remembering the names of the controls on the sheet.
If you do not know the name of the toggle button you can look at the
properties of it on the sheet. It is the name property. You can also double
click it if you are in design mode and it will open the code for the toggle
button and you will see the name. Remember to use the code snippet provided
in the code under the command button.

Let me know if this still does not make sense. I will check my email
tomorrow.
 
G

Gary Keramidas

i know it is togglebutton1. when i put Me.tglTest = False in the code, get a
message, invalid use of Me keyword
 
G

Guest

I'm glad you got it. ToggleButton1 is the default name for a toggle button.
I usually rename the controls I put on a form to standard naming conventions.
Sorry about the confusion. Did you notice the auto list that displayed when
you typed "Me."? You should have been able to type Tog and it would have
taken you right to the ToggleButton1 control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top