Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar control

Status
Not open for further replies.

fpoirier

Programmer
Joined
Sep 12, 2003
Messages
6
Location
CA
Hello, I hope this can help someone.

I use only one calendar control for all my Word VBA application... when the user click on a calendar image I change the caption of the userform (calendar form) before showing it... and when the user accept the date (click ok) I return the date to the good date field (textbox). So my application have 12 date field... but I only use 1 userform form and 1 calendar control to do it.

' to show the calendar
Private Sub Image3_Click()
UserForm11.Caption = "Begin Date..."
If IsDate(UserForm2.TextBox45) Then 'if a good date have been choosen or typed
UserForm11.Calendar1.Value = UserForm2.TextBox45
Else
UserForm11.Calendar1.Value = "01/01/1986" 'else default date...
End If
UserForm11.Show

' <OK> to accept the date
Private Sub CommandButton1_Click()
If UserForm11.Caption = &quot;End Date...&quot; Then
UserForm4.TextBox22.Value = Calendar1.Value
UserForm11.Hide
End If
If UserForm11.Caption = &quot;Begin Date...&quot; Then
UserForm2.TextBox45.Value = Calendar1.Value
UserForm11.Hide
End If
....
* I could use a SELECT CASE in place of IF...

Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top