Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Reset All Command Buttons on an Excel UserForm

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Reset All Command Buttons on an Excel UserForm

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Reset All Command Buttons on an Excel UserForm

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Reset All Command Buttons on an Excel UserForm

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Reset All Command Buttons on an Excel UserForm

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Command Buttons Newbee Excel Worksheet Functions 4 November 21st 06 07:03 PM
How can I reset an Excel form that has radio buttons. JaxPM Excel Programming 5 May 4th 06 03:51 AM
Naming command buttons on a UserForm Casey[_65_] Excel Programming 3 April 7th 06 04:47 PM
adding userform command buttons borg Excel Programming 3 April 2nd 06 05:14 PM
Command buttons in Excel bigwheel[_2_] Excel Programming 0 September 7th 04 08:30 PM


All times are GMT +1. The time now is 03:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"