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,
 
There is a hidden commandbutton uderlying the frmCalendar. The code for the commandbutton is:

Private Sub CommandButton1_Click()
frmCalendar.Hide
End Sub

The cancel property of the commandbutton is set as True. I just thought it would be appropriate to allow users to close the Calendar by just pressing Esc in the Keyboard. This is working fine. But when the users click on the X, the calendar as well as the main form both gets closed.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi there,

I need advice for same case like above. I have already follow the instruction by using below code. but it's only work for TextBox3. TextBox8 & TextBox9 remains blank. Please help. :)
Thank you

Userform1
Code:
Private Sub CommandButton1_Click()
Calendar.Show
End Sub
Private Sub CommandButton2_Click()
Calendar.Show
End Sub
Private Sub CommandButton3_Click()
Calendar.Show
End Sub

Calendar1
Code:
Private Sub Calendar1_Click()
    With UserForm1
        Select Case .ActiveControl.Name
            Case "CommandButton1"
                .TextBox3.Value = Format(Calendar1.Value, "dd mmmm yyyy")
            Case "CommandButton2"
                .TextBox8.Value = Format(Calendar1.Value, "dd mmmm yyyy")
            Case "CommandButton3"
                .TextBox9.Value = Format(Calendar1.Value, "dd mmmm yyyy")
        End Select
    End With
    Unload Me
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
 
Upvote 0
there is no error while I'm testing the userform. the textbox8 & textbox9 only remain blank even I already pick a date from calendar control. FYI, i'm using Word Macro and I create these 2 textbox within a Frame (the success one is outside Frame), but still in a single form.
Please advice if I must give any detail. I'm new with macro programming. :)
thank you.

Cheers,
Mei
 
Upvote 0
Hi Andrew,

after a while, I'm thinking about the "almost" same case with the multipage.
i try below code and it works well. :)
Thanks for your reference. thumbs up.

Code:
Private Sub Calendar1_Click()
    With UserForm1
        Select Case .ActiveControl.Name
            Case "CommandButton1"
                .TextBox3.Value = Format(Calendar1.Value, "dd mmmm yyyy")
        End Select
        Select Case .Frame1.ActiveControl.Name
            Case "Cmd_awal"
                .TextBox11.Value = Format(Calendar1.Value, "dd mmmm yyyy")
            Case "CommandButton3"
                .TextBox12.Value = Format(Calendar1.Value, "dd mmmm yyyy")
        End Select
    End With
    Unload Me
End Sub
 
Upvote 0
Are your CommandButtons also in a frame?

Code:
Private Sub Calendar1_Click()
    With UserForm1
        Select Case TypeName(.ActiveControl)
            Case "CommandButton"
                Select Case .ActiveControl.Name
                    Case "CommandButton1"
                    .TextBox3.Value = Format(Calendar1.Value, "dd mmmm yyyy")
                End Select
            Case "Frame"
                Select Case .ActiveControl.ActiveControl.Name
                    Case "CommandButton2"
                        .TextBox8.Value = Format(Calendar1.Value, "dd mmmm yyyy")
                    Case "CommandButton3"
                        .TextBox9.Value = Format(Calendar1.Value, "dd mmmm yyyy")
                End Select
        End Select
    End With
    Unload Me
End Sub
 
Upvote 0
niceeee....your code works well. I still met problems using my last posted code. :)
Thank you Andrew. btw, can I ask other case here? or should I create new thread?
Please advice.

Cheers,
Mei
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,224
Members
453,152
Latest member
ChrisMd

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