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 = "End Date..." Then
UserForm4.TextBox22.Value = Calendar1.Value
UserForm11.Hide
End If
If UserForm11.Caption = "Begin Date..." Then
UserForm2.TextBox45.Value = Calendar1.Value
UserForm11.Hide
End If
....
* I could use a SELECT CASE in place of IF...
Frank
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 = "End Date..." Then
UserForm4.TextBox22.Value = Calendar1.Value
UserForm11.Hide
End If
If UserForm11.Caption = "Begin Date..." Then
UserForm2.TextBox45.Value = Calendar1.Value
UserForm11.Hide
End If
....
* I could use a SELECT CASE in place of IF...
Frank