Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Preventing a command button from being clicked twice

I am using excel 2003 to keep lap times in a dirt bike race. I have a command
button that is clicked to record the time the race starts. The code is below.

Private Sub StartButton_Click()
Worksheets("Timing Sheet").Range("A6").Value = Format(Now, "h:mm:ss")
End Sub

What I need to do is to ensure that the button is not clicked accidently
after the race has started. Is there a way that I can count how many times it
has been clicked and if it is more than once it comes up with a warning along
the lines of "the race has started are you sure you want to change the race
start time" with a yes/no option.

The other thing I would like to do is store a backup copy of the original
start time somewhere else in the worksheet in a way that it is nopt updated
every time the button is clicked.

Any help will be gladly appreciated.

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 915
Default Preventing a command button from being clicked twice

NDBC wrote:
I am using excel 2003 to keep lap times in a dirt bike race. I have a command
button that is clicked to record the time the race starts. The code is below.

Private Sub StartButton_Click()
Worksheets("Timing Sheet").Range("A6").Value = Format(Now, "h:mm:ss")
End Sub

What I need to do is to ensure that the button is not clicked accidently
after the race has started. Is there a way that I can count how many times it
has been clicked and if it is more than once it comes up with a warning along
the lines of "the race has started are you sure you want to change the race
start time" with a yes/no option.

The other thing I would like to do is store a backup copy of the original
start time somewhere else in the worksheet in a way that it is nopt updated
every time the button is clicked.

Any help will be gladly appreciated.

Thank you


Another idea is to disable the StartButton after it is clicked:
StartButton.Enabled = False

Then set the value to True after satisfying some condition (e.g., when
the StopButton is clicked, if you have such).

If you want to keep counts you can create a module- or form-level
variable that you increment in the button click event. Do this by
declaring said variable at the top of the module, just under "Option
Explicit" (if you have that) and prior to any subs or functions. Don't
forget to reset this variable appropriately.

You might not actually need to store a backup copy of start time if you
try out the above ideas, but if you want to do it anyway you can store
it in another module- or form- level variable, or write something like

Range("AZ999").Value = Range("A6").Value

Just make sure this line is not called on subsequent clicks.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Preventing a command button from being clicked twice

I would suggest to disable the start button once the user click start and if
the user want to stop let there be another button to do that. When they hit
stop OR when the macro ends you can enable the start button.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I am using excel 2003 to keep lap times in a dirt bike race. I have a command
button that is clicked to record the time the race starts. The code is below.

Private Sub StartButton_Click()
Worksheets("Timing Sheet").Range("A6").Value = Format(Now, "h:mm:ss")
End Sub

What I need to do is to ensure that the button is not clicked accidently
after the race has started. Is there a way that I can count how many times it
has been clicked and if it is more than once it comes up with a warning along
the lines of "the race has started are you sure you want to change the race
start time" with a yes/no option.

The other thing I would like to do is store a backup copy of the original
start time somewhere else in the worksheet in a way that it is nopt updated
every time the button is clicked.

Any help will be gladly appreciated.

Thank you

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
When clicked, the Button needs to create a number in another cell Clark Excel Worksheet Functions 0 August 20th 08 11:07 PM
Change Macro button color after clicked Cong Nguyen Excel Discussion (Misc queries) 2 November 30th 07 02:55 PM
Excel 2007 Crashes Whenever Add-In Button is Clicked Richard S Setting up and Configuration of Excel 0 August 28th 07 12:50 AM
let a sub recognise the name of the button that has been clicked. Brotherwarren Excel Discussion (Misc queries) 2 March 18th 06 10:56 AM
preventing button being pressed Mike Excel Discussion (Misc queries) 2 March 16th 06 03:47 PM


All times are GMT +1. The time now is 09:59 PM.

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

About Us

"It's about Microsoft Excel"