Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform, Calender, Problems with Todays Date
Hi,
I have a userform that contains a textbox where a user would enter a date. To get around the many problems of people using / or : or ; as date seperators, when the user selects the TextBox a second userform appears using the Calender tool, the user then clicks on the correct date and the second userform disappears and the date is now showing in the textbox. This all works fine apart from one small problem, I cannot get the calender to default to todays date. The code I am using is as follows: When the user selects the TextBox In UserForm2. Private Sub StartDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UserForm1.Show End Sub The code behind the Calender in UserForm1. Private Sub Calendar1_Click() UserForm2.ActiveControl.Value = Me.Calendar1.Value UserForm2.ActiveControl.Value = Format(Me.Calendar1.Value, "dd/mm/yyyy") UserForm2.ActiveControl.SetFocus Unload Me End Sub I can't remember who I have to thank for the above code, so if you recognise it - Thanks!! Any help in getting the UserForm1 calender to default to todays date would be greatly appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform, Calender, Problems with Todays Date
you can use the ENTER event for the text box ...
//Userform2// Private Sub TextBox1_Enter() UserForm1.Show End Sub and in Userform1, use the click event of the calendar control... //Userform1// Private Sub UserForm_Initialize() Calendar1.Value = Date End Sub Private Sub Calendar1_Click() UserForm2.TextBox1.Text = Format$(Calendar1.Value, "DD-mmm-yyyy") End Sub "BaggieDan" wrote: Hi, I have a userform that contains a textbox where a user would enter a date. To get around the many problems of people using / or : or ; as date seperators, when the user selects the TextBox a second userform appears using the Calender tool, the user then clicks on the correct date and the second userform disappears and the date is now showing in the textbox. This all works fine apart from one small problem, I cannot get the calender to default to todays date. The code I am using is as follows: When the user selects the TextBox In UserForm2. Private Sub StartDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UserForm1.Show End Sub The code behind the Calender in UserForm1. Private Sub Calendar1_Click() UserForm2.ActiveControl.Value = Me.Calendar1.Value UserForm2.ActiveControl.Value = Format(Me.Calendar1.Value, "dd/mm/yyyy") UserForm2.ActiveControl.SetFocus Unload Me End Sub I can't remember who I have to thank for the above code, so if you recognise it - Thanks!! Any help in getting the UserForm1 calender to default to todays date would be greatly appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform, Calender, Problems with Todays Date
why not use a datepicker control and forhget usign ab=nother userform?
"BaggieDan" wrote: Hi, I have a userform that contains a textbox where a user would enter a date. To get around the many problems of people using / or : or ; as date seperators, when the user selects the TextBox a second userform appears using the Calender tool, the user then clicks on the correct date and the second userform disappears and the date is now showing in the textbox. This all works fine apart from one small problem, I cannot get the calender to default to todays date. The code I am using is as follows: When the user selects the TextBox In UserForm2. Private Sub StartDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UserForm1.Show End Sub The code behind the Calender in UserForm1. Private Sub Calendar1_Click() UserForm2.ActiveControl.Value = Me.Calendar1.Value UserForm2.ActiveControl.Value = Format(Me.Calendar1.Value, "dd/mm/yyyy") UserForm2.ActiveControl.SetFocus Unload Me End Sub I can't remember who I have to thank for the above code, so if you recognise it - Thanks!! Any help in getting the UserForm1 calender to default to todays date would be greatly appreciated. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform, Calender, Problems with Todays Date
my keyboard is hopping around again ;)
"why not use a datepicker control and forget using another userform?" regards "Patrick Molloy" wrote: why not use a datepicker control and forhget usign ab=nother userform? "BaggieDan" wrote: Hi, I have a userform that contains a textbox where a user would enter a date. To get around the many problems of people using / or : or ; as date seperators, when the user selects the TextBox a second userform appears using the Calender tool, the user then clicks on the correct date and the second userform disappears and the date is now showing in the textbox. This all works fine apart from one small problem, I cannot get the calender to default to todays date. The code I am using is as follows: When the user selects the TextBox In UserForm2. Private Sub StartDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UserForm1.Show End Sub The code behind the Calender in UserForm1. Private Sub Calendar1_Click() UserForm2.ActiveControl.Value = Me.Calendar1.Value UserForm2.ActiveControl.Value = Format(Me.Calendar1.Value, "dd/mm/yyyy") UserForm2.ActiveControl.SetFocus Unload Me End Sub I can't remember who I have to thank for the above code, so if you recognise it - Thanks!! Any help in getting the UserForm1 calender to default to todays date would be greatly appreciated. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform, Calender, Problems with Todays Date
This is the one that worked for me!
I did just add Unload UserForm1 to : Private Sub Calendar1_Click() UserForm2.TextBox1.Text = Format$(Calendar1.Value, "DD-mmm-yyyy") Unload UserForm1 End Sub To shift it out of the way! I am not familiar with a datepicker control - I shall investigate further. Thanks! "Patrick Molloy" wrote: you can use the ENTER event for the text box ... //Userform2// Private Sub TextBox1_Enter() UserForm1.Show End Sub and in Userform1, use the click event of the calendar control... //Userform1// Private Sub UserForm_Initialize() Calendar1.Value = Date End Sub Private Sub Calendar1_Click() UserForm2.TextBox1.Text = Format$(Calendar1.Value, "DD-mmm-yyyy") End Sub "BaggieDan" wrote: Hi, I have a userform that contains a textbox where a user would enter a date. To get around the many problems of people using / or : or ; as date seperators, when the user selects the TextBox a second userform appears using the Calender tool, the user then clicks on the correct date and the second userform disappears and the date is now showing in the textbox. This all works fine apart from one small problem, I cannot get the calender to default to todays date. The code I am using is as follows: When the user selects the TextBox In UserForm2. Private Sub StartDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) UserForm1.Show End Sub The code behind the Calender in UserForm1. Private Sub Calendar1_Click() UserForm2.ActiveControl.Value = Me.Calendar1.Value UserForm2.ActiveControl.Value = Format(Me.Calendar1.Value, "dd/mm/yyyy") UserForm2.ActiveControl.SetFocus Unload Me End Sub I can't remember who I have to thank for the above code, so if you recognise it - Thanks!! Any help in getting the UserForm1 calender to default to todays date would be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Having problems with a calender | Excel Discussion (Misc queries) | |||
pop up calender in a userform | Excel Programming | |||
VBA Calender Formatting Date Problems | Excel Programming | |||
Create a button that will date stamp todays date in a cell | Excel Discussion (Misc queries) | |||
When I open my past invoice it keeps changing date to todays date | Excel Worksheet Functions |