Disable Form button at a fixed time

tvman5683

Board Regular
Joined
Mar 23, 2009
Messages
94
Hello,
I have a form with a button that appends to a external text file. It is used by multiple users. The text file is captured at 3:00 PM for processing. I want to stop any after 3:00 PM activity.
Is there a way to disable the button based on the internal clock?

Thanks for any help
JB
 
You will need a timer event; easier to just put it on this form, but you could create a timer form and make it hidden. A value of 1000 for the timer event is 1 second. Don't check too often lest you slow down processing or make things choppy. In the timer event put something like
Code:
If Time >= TimeValue("10:00") Then
  Me.cmdButtonName.enabled = False
  Me.Repaint
End If
If you use a separate form, you need the correct forms reference:

Forms!frmFormName.cmdButtonName.Enabled = False
Forms!frmFormName.Repaint

but you should ensure the main form is open first - If CurrentProject.Allforms("frmName").IsLoaded Then
You can get fancy with this. A computation in the code block could alter the interval by half of the time difference between your appointed hour and the current time, up to a minimum value, but the form open event should be coded to re-start it at your value. Otherwise, you could end up arriving at the time and the timer event doesn't fire until some time afterwards. This operation could also get its start interval and target time from a table so you don't have to modify code. Let me know if you want to embellish the process and if so, how and I'll code something for you.
 
Last edited:
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,221,829
Messages
6,162,229
Members
451,756
Latest member
tommyw

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