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
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I assume by Form you mean UserForm? if so, try adding following to your forms Initialize event & see if this does what you want.

Code:
Private Sub UserForm_Initialize()
    Me.CommandButton1.Enabled = Not Time >= TimeValue("15:00")
End Sub

Change commandbutton name as required.

Dave
 
Last edited:
Upvote 0
Thanks Dave, I will give it a try.
can I also add a MsgBox ("3:00 PM deadline has Expired")

Try:

Code:
Private Sub UserForm_Initialize()
    With Me.CommandButton1
        .Enabled = Not Time >= TimeValue("15:00")
        If Not .Enabled Then MsgBox "3:00 PM deadline has Expired", 16, "Time Expired"
    End With
End Sub

Dave
 
Upvote 0
Since this is the Access forum section, you would not use UserForm or Initialize. It would be Private Sub Form_Open(Cancel As Integer). Better to do this on the open event rather than the Load event. This assumes you want the message after 15:00 regardless of what else they may be able to do with the form.
 
Last edited:
Upvote 0
Tried this as a test but did not work. I didn't see an "Initialize" selection in the for properties list so i just pasted the code in.
also my button name had spaces so I bracketed. Not sure if that's the cause of the failure??

JB




Private Sub Form_Initialize()
With Me.[Append to Daily]
.Enabled = Not Time >= TimeValue("08:00")
If Not .Enabled Then MsgBox "3:00 PM deadline has Expired", 16, "Time Expired"
End With
End Sub
 
Upvote 0
My apologies but it won't as I picked this thread up in an Excel Forum & just assumed you were using Excel. Look at post #5
 
Last edited:
Upvote 0
Thanks Micron,
That did seem to disable the button using the 8:00 AM time. I reset to 9:30 to see if it goes from active to disabled.

Thanks aslo to Dave for the original code.

JB
 
Upvote 0
It works perfectly if you open the database after the time deadline. but if you have the form open and the deadline passes the button still works. So is there another form property besides _Open that would work anytime?

Thanks
JB
 
Upvote 0

Forum statistics

Threads
1,221,829
Messages
6,162,232
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