ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calendar Contol with mutiple textboxes (https://www.excelbanter.com/excel-programming/392991-calendar-contol-mutiple-textboxes.html)

Corey

Calendar Contol with mutiple textboxes
 
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....



Incidental

Calendar Contol with mutiple textboxes
 
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



All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com