Disabling Command Button

J

JamesJ

Hi. I placed the Activex Calendar control (axcCalendar) and a command button
(cmdToday)
on an unbound form. The command button when clicked returns axcCalendar to
today if
need be. Although there are no problems I would like cmdToday to be disabled
if axcCalendar's
current day is selected. I've placed the following in several places
including the OnCurrent of the
form and the OnUpdated of axcCalendar with no success.

Private Sub axcCalendar_Updated(Code As Integer)

If Me!axcCalendar.Today Then

Me!cmdToday.Enabled = False

Else

Me!cmdToday.Enabled = True

End If

End Sub

I've also tried replacing the first line with:

If Me!axcCalendar.Value = Date

Any help will be appreciated.

Thanks,
James
 
T

Tony C

A couple of things here: -

1. The code needs to be applied to the controls "On Exit"
procedure, if you have the code on the "After Update"
procedure it will not work.
2. You need to compare dates by using the following
code: -

Me.cmdToday.Enabled=True
If Me.axcCalendar.Value <> Date() Then Exit Sub
Me.cmdToday.Enabled=False

HTH

Tony C
 

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