Date Help

B

Bill Davis

I am using and calendar control and I am wanting to set
the control so that it will check to see if the date
entered is greater than today's date and if it is to
display a message. I am not having as success in getting
the code to work in the AfterUpdate or on Change event. I
can get it to work on a text box that does not use
calendar control..

Calendar control code:
Private Sub txbresearchcompdate_MouseDown(Button As
Integer, Shift As Integer, X As Single, Y As Single)
Set cbooriginator = txbresearchcompdate
Calendar5.Visible = True
Calendar5.SetFocus
If Not IsNull(cbooriginator) Then
Calendar5.Value = cbooriginator.Value
Else
Calendar5.Value = Date
End If
End Sub

AfterUpdate Code:

Private Sub txbresearchcompdate_AfterUpdate()
If Calendar5.Value >= Date Then
MsgBox "Please enter a date that is not greater than
today's date."
End If
 

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