Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm a little confused what you are trying to do with your CommandButtons.
What do you mean by "reset all the other buttons to false" as it applies to your CommandButtons? Exactly what are you trying to do with the CommandButtons? -- Rick (MVP - Excel) wrote in message ... Hi, I’m hoping someone can help with this. I have a workbook with some 80 user forms each one containing up to 40 command buttons. I would like to add another command button which when pressed will reset all of the other buttons to false. THis function will enable the user to 'refresh' the form should he make a mistake. I do not want to reload (Unload Me) the form as there is some information pre popluated which has to be kept. I have been scouring the internet for a couple of days now and the closest I have come is: Private Sub ClearAllTextboxes() Dim objTemp As Control For Each objTemp In Me.Controls If TypeOf objTemp Is TextBox Then objTemp.Text = "" Next End Sub This code as you can see was used to clear text from various text boxes on a form, however, by substituting “TextBox” for “CommandButton” and “.Text = “”” for “.Visible = False” I can get all of the buttons to disappear, including the “Reset Button” which makes me think this piece of code would suit if only I knew what should be used in place of “.Text = “”” I am using Boolean with the commandbuttons. Hope you can help. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick,
Basically I am creating is an Electronic Point of Sale type of tool. So as the user selects (pushes) each button from the selection 2 text boxes are populated with strings of text, 1 is a code and the other is wording reflecting the code. However, as testing has gone on it has become apparent from the users that they would like the ability to 'reset' the form i.e. cancel all selections and return the form to its initial state. I do not want to use 'Unload Me' because on initial opening of the form the user is requested via 3 pop up forms to enter certain data which is then displayed on the main form. When the buttons are selected the boolean becomes true, e.g. Private Sub CommandButton9_Click() If booCommandButton9 = False Then booCommandButton9 = True Else: booCommandButton9 = False End If If booCommandButton9 Then CommandButton9.BackColor = &HFFFFFF Else: CommandButton9.BackColor = &H808080 End If Call StringBuilder End Sub I would like the reset button to set the buttons to their initial state and clear the text boxes (I think I know how to reset the text boxes but there may be a routine which will reset the buttons and text boxes together (?). As I said in my initial message, the code I posted seems to be something like I need if only I knew what to replace the last part with. Hopefully I have managed to clarify what I am after. Thanks for your assistance. Glen |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe you should be looking at ToggleButtons (not commandbuttons), but I'm
confused too. Regards, Peter T wrote in message ... Rick, Basically I am creating is an Electronic Point of Sale type of tool. So as the user selects (pushes) each button from the selection 2 text boxes are populated with strings of text, 1 is a code and the other is wording reflecting the code. However, as testing has gone on it has become apparent from the users that they would like the ability to 'reset' the form i.e. cancel all selections and return the form to its initial state. I do not want to use 'Unload Me' because on initial opening of the form the user is requested via 3 pop up forms to enter certain data which is then displayed on the main form. When the buttons are selected the boolean becomes true, e.g. Private Sub CommandButton9_Click() If booCommandButton9 = False Then booCommandButton9 = True Else: booCommandButton9 = False End If If booCommandButton9 Then CommandButton9.BackColor = &HFFFFFF Else: CommandButton9.BackColor = &H808080 End If Call StringBuilder End Sub I would like the reset button to set the buttons to their initial state and clear the text boxes (I think I know how to reset the text boxes but there may be a routine which will reset the buttons and text boxes together (?). As I said in my initial message, the code I posted seems to be something like I need if only I knew what to replace the last part with. Hopefully I have managed to clarify what I am after. Thanks for your assistance. Glen |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
By toggle buttons do you mean radio buttons? The reason for commandbuttons is that the HMI is a touchscreen with data being entered by personnel wearing gloves (sometimes). We initially had radio buttons and check boxes but these proved to be too small for gloved fingers, hence the reason for the commandbutton choice. Please let me know which part of my question you are confused with and I will try and clarify further. Thanks, Glen |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
By toggle buttons do you mean radio buttons?
No I meant "ToggleButton" controls. These can look like CommandButtons but they can be raised or depressed, as reflected or changed by the Value property (which fires its click event). By default they do not work like radio buttons (OptionButtons) though with a little more code they can be made to do so. Put two ToggleButton's on the form, run the form and repeatedly click the form to toggle all of them Private Sub ToggleButton1_Click() If Me.ToggleButton1.Value Then ' do depressed state stuff Else ' do raised state stuff End If End Sub Private Sub UserForm_Click() Dim ctrl As MSForms.Control Static bVal As Boolean bVal = Not bVal For Each ctrl In Me.Controls If TypeName(ctrl) = "ToggleButton" Then ctrl.Value = bVal End If Next End Sub Regards, Peter T wrote in message ... Peter, By toggle buttons do you mean radio buttons? The reason for commandbuttons is that the HMI is a touchscreen with data being entered by personnel wearing gloves (sometimes). We initially had radio buttons and check boxes but these proved to be too small for gloved fingers, hence the reason for the commandbutton choice. Please let me know which part of my question you are confused with and I will try and clarify further. Thanks, Glen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Command Buttons | Excel Worksheet Functions | |||
How can I reset an Excel form that has radio buttons. | Excel Programming | |||
Naming command buttons on a UserForm | Excel Programming | |||
adding userform command buttons | Excel Programming | |||
Command buttons in Excel | Excel Programming |