Activating a command button after a certain date passes.

G

Guest

I am trying to code a cmd button to be active once a certain date passes.
For example I am setting up a database form that will show sales for November
and December but don't want the December button to be active until December
2nd. The button name is cmdDecSales. I am trying to apply this code when
the Form Opens. Any help would be appreciated.

Thanks,
Chris
 
S

Stefan Hoffmann

hi Chris,
I am trying to code a cmd button to be active once a certain date passes.
For example I am setting up a database form that will show sales for November
and December but don't want the December button to be active until December
2nd. The button name is cmdDecSales. I am trying to apply this code when
the Form Opens. Any help would be appreciated.

Private Sub Form_Open(Cancel As Integer)

cmdDecSales.Enabled = (Date() > #12/01/2006#)

End Sub


mfG
--> stefan <--
 
G

Guest

Thanks Stefan.

Stefan Hoffmann said:
hi Chris,


Private Sub Form_Open(Cancel As Integer)

cmdDecSales.Enabled = (Date() > #12/01/2006#)

End Sub


mfG
--> stefan <--
 
M

Marshall Barton

Chris said:
I am trying to code a cmd button to be active once a certain date passes.
For example I am setting up a database form that will show sales for November
and December but don't want the December button to be active until December
2nd. The button name is cmdDecSales. I am trying to apply this code when
the Form Opens.


Me.cmdDecSales.Enabled = (Format(Date,"mmdd") >= "1202")

Because your example was for December, I can't tell what you
want to happen in January. The line above will disable the
button again until the next December.

If you have a button for each month and want all the months
to be enabled only during the month:

Me.cmdDecSales.Enabled = (Month(Date) = 12)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top