Calendar date in Textbox

#BoB#

Active Member
Joined
May 20, 2008
Messages
303
Hi,

I have a form where i need to enter date in a textbox from a calendar.

I have created a calendar which opens on clicking a button adjuscent to the textbox.

Now I am not able to enter the selected date from the calendar into the textbox.

Any help would be greately appreciated.


Regards,
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Andrew,

The code I am using is:

frmCalendar.Show
Textbox1.Value = Calendar.Value
Unload Me

This works fiine if I use a cell instead of a textbox.


Thanks in advance,
 
Upvote 0
Code in UserForm1:

Code:
Private Sub CommandButton1_Click()
    frmCalendar.Show
End Sub

Code in frmCalendar:

Code:
Private Sub Calendar1_Click()
    UserForm1.TextBox1.Value = Calendar1.Value
    Unload Me
End Sub
 
Upvote 0
Thanks Andrew,

This has really solved my problem. But just wondering if I can have little more help in calendars..

I need dates in different textboxes across different tabs of a multipage. Right now I have created different calendars to be used in each of these textboxes.

When I click a button adjuscent to a particular textbox, the relevent calendar pops up.

Isn't it possible to use just one calendar in all the textboxes, and when I click the button to call a calendar and select a date, just the textbox adjuscent to the button gets the data.

I tried to create the Calendar in a Personal Macro workbook and then call it from my userform. But not able to make it pass the data onto the textbox (although it works fine if i use a cell instead of a textbox).

I will really appreciate any help in it.

Regards
 
Upvote 0
Example:

Code:
Private Sub Calendar1_Click()
    With UserForm1
        Select Case .ActiveControl.Name
            Case "CommandButton1"
                .TextBox1.Value = Calendar1.Value
            Case "CommandButton2"
                .TextBox2.Value = Calendar1.Value
        End Select
    End With
    Unload Me
End Sub
 
Upvote 0
Hi Andrew,

The Activecontrol in my case is showing as Multipage1 instead of Commandbutton1

Therefore, the case statements are not able to fetch the date into the textbox :(
 
Upvote 0
Try eg:

Code:
Private Sub Calendar1_Click()
   With UserForm1
      Select Case .ActiveControl.Name
         Case "MultiPage1"
            Select Case .MultiPage1.Value
               Case 0
                  Select Case .MultiPage1.Pages(0).ActiveControl.Name
                     Case "CommandButton1"
                        .TextBox1.Value = Calendar1.Value
                     Case "CommandButton2"
                        .TextBox2.Value = Calendar1.Value
                  End Select
               Case 1
                  Select Case .MultiPage1.Pages(1).ActiveControl.Name
                     Case "CommandButton3"
                        .TextBox3.Value = Calendar1.Value
                     Case "CommandButton4"
                        .TextBox4.Value = Calendar1.Value
                  End Select
            End Select
      End Select
   End With
   Unload Me
End Sub
 
Upvote 0
Thanks Andrew. You have been of great help throughout. The code really worked well.

Now, this is probably my last question related to calendar.

When I select a date in the calander, it gets unloaded, and the date appears in the related textbox.

But if I close the calendar by clicking the X in the upper ritht corner, it closes down both the calendar as well as the main Userform.

Any idea how to tackle this?
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top