Calendar Contol with mutiple textboxes

C

Corey

I am using the Textbox_Entyer event to trigger the frmCalender to appear and when a date is selected
it places the date into Textbox1

However further down on the form i have another date textbox (Textbox33)

How can use the SAME frmCalendar to input the date here into Textbox33 as with Textbox1 ?

As the code line i am using to input the date from the Calendar is :


Private Sub Calendar1_Click()
With UserForm1
TextBox1.Value = Calendar1.Value
Unload Me
End Sub

Is there a way to have something like:

Activetextbox or If textbox.setfocus = true then

They did not work though

I do not want to add a2nd frmCalendar


Corey....
 
I

Incidental

Hi Corey

I don't have the calendar control installed on this computer but i
believe the code below should work for you though i can't test it as i
said.

Option Explicit
Dim Ctrl As MSForms.Control

Private Sub TextBox1_Enter()
Set Ctrl = UserForm1.Controls("TextBox1")
'call calendar control
End Sub

Private Sub TextBox33_Enter()
Set Ctrl = UserForm1.Controls("TextBox33")
'call calendar control
End Sub

Private Sub Calendar1_Click()
Ctrl.Value = Calendar1.Value
Unload Me
End Sub

hope this helps

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top