I'm using MS Excel 2007 UserForms to gather parameter information used with SQL stored procedures. Each UserForm contains at least one textbox used to capture a date value. I've been trying to make use of a single userform with a calendar control to set the various date field values found on my collection of userforms, but have not been successful at setting an object variable on the calendar userform to a reference of the calling textbox.
Within the code behind the calendar control's userform, I've created a public variable like so:
Public dateControl As MSForms.textbox
The procedure used to set the associated textbox value is:
Private Sub Calendar1_Click()
dateControl.Text = Calendar1.Value
The code used to set the dateControl to a reference of a textbox on another userform is:
Private Sub imgBeginDate_Click()
Set frmCalendar.dateControl = frmEarnedHours.Controls(txtBeginDate)
Does anyone know how to perform this reference to a textbox on another userform, or am I going to have to create a specific calendar for each textbox which captures a date?