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?
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:
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.
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.