Userform hide problem

Adi21

Board Regular
Joined
Aug 11, 2014
Messages
62
Hi, I have a little problem with hiding a Userform.
So, I have a Userfrom called "Userform2" and there I have a textbox. When I click the textbox appear another Userform,called "Calendar1", which is a Date Picker. What I want: when I choose the date, the Userform Calendar1 needs to hide,or unload,something like that. But I get error. If somebody can help me?
Thanks
Code:
Private Sub Calendar1_Click()
UserForm1.JoinDateTxt.Value = Format(Calendar1.Value, "dd/mmm/yy")
Calendar1.Unload
End Sub

Code:
Private Sub JoinDateTxt_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  Calendar1.Show
    If Len(JoinDateTxt.Text) > 0 Then
        JoinDateNum = DatePart("d", JoinDateTxt) - 1
    End If
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try this.
Code:
Unload Me
PS If the form is called Calendar1and you also have a control named Calendar1 on the form that's not a good idea.
 
Upvote 0
Yes, I have the Userform called "Calendar1" and also there I have a MonthView called again "Calendar1". I will modify one of them.Thanks.
Now, I tried with Unload Me, but when I select data is not writing the date in the textbox and the Userform Calendar1 is not unload and if I try to click exit I get the error with type mismatch in this line:
Code:
 JoinDateNum = DatePart("d", JoinDateTxt) - 1
 
Upvote 0
How did you try Unload Me?

The type mismatch could be because DatePart is returning text.
 
Upvote 0
Like this:
Code:
Private Sub Calendar1_Click()
UserForm1.JoinDateTxt.Value = Format(Calendar1.Value, "dd/mmm/yy")
Unload me
End Sub
Yes, the text box didn`t get anymore the date and that is why I get that error, but I don`t know why is not working.
 
Upvote 0

Forum statistics

Threads
1,222,312
Messages
6,165,268
Members
451,949
Latest member
bovacik

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