troubleshooting Question

MS Excel - Set UserForm Object Variable from another UserForm

Avatar of C_Patrick
C_PatrickFlag for United States of America asked on
Microsoft ApplicationsMicrosoft Excel
8 Comments1 Solution437 ViewsLast Modified:
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()
         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?

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros