Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Dear All,

I am using a calendar control in excel on a user form and want to enter the date that is selected in the calendar into a text box on the user form.

I am sure this is easy, but I am getting frustrated with this.

Thanks

 


Private Sub Calendar1_Click()
TextBox1.Value = Calendar1.Value
End Sub
 
thanks for that response, I can get this to work fine, when however I try to also save the result of the calendar also to a different place(a1), using [A1] = calendar1.value,(coding under above line in procedure) the calendara does strange things, It thinks the first 12 days in a month are months, so when I click on say the 1st august, it shows the 1-jan-02, and then the 2nd of the month shows 2-feb-02, and so on upto the 12th of the month, but when it gets to the 13th it rectifies it's self, does anyone know why this is doing that?
The reason why I want to do this is i am using the calendar to get the user to select a date for which they want to run a report, then there is a combo box for which they select a report, and what I want to do is then add the value of the text box and combo box in a new text box at the bottom of the form, so the user can see what date the report they have select will run on. then the user will select the run report button and the report will be ran. Ithought if I copy the data to the SS and then take the value from the SS and then enter back into the new textbox this would be easy, but it ain't working. Any great ideas going out there on how to do this supposedly simple task to work?




 
Hi robcarr

Maybe check the date format under the regional settings in your control panel and ensure that short date is something like mm/dd/yyyy and long date is dddd, mmmm dd yyyy

also force the format you prefer

Private Sub Calendar1_Click()
Sheets("Sheet1").Cells(1, 1).Value = Format(Calendar1.Value, "mm/dd/yyyy")
End Sub

Hope it helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top