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
End Sub
The code used to set the dateControl to a reference of a textbox on another userform is:
Private Sub imgBeginDate_Click()
frmCalendar.Show
Set frmCalendar.dateControl = frmEarnedHours.Controls(txtBeginDate)
End Sub
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?
Thanks!
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.