View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Marcus B Marcus B is offline
external usenet poster
 
Posts: 5
Default Calendar Control & ActiveControl

Hi,

I have a form with a number of text boxes that require a date value. I want
to use a calendar control form to update each of these text boxes.

My problem is I don't know how to efficiently reference the text boxes to
the calendar control.

At the moment I am trying to use the ActiveControl method in the form code
as below:

Private Sub UserForm_Initialize()
' Check if control with focus contains a date. If 'yes' show
' same date on calendar. If 'no' show today's date.
If IsDate(UserForm2.ActiveControl.Value) Then
Calendar1.Value = DateValue(UserForm2.ActiveControl.Value)
Else
Calendar1.Value = Date
End If
End Sub

Private Sub Calendar1_Click()
' Transfer date selected on calendar to control with focus
UserForm2.ActiveControl.Value = Calendar1.Value
frmCalendar.Unload
End Sub

The the calendar is is triggered using the enter method for each textbox
selected.
e.g.
Private Sub txReviewDate_Enter()
frmCalendar.Show
End Sub

I think the problem may be to do with using the enter event with the
ActiveControl method as the textbox will not yet have focus.

Any help appreciated.
Thanks,
Marcus