Problem with pop up calendar

rustym

New Member
Joined
Jul 22, 2010
Messages
18
Hey guys,

I am working on a macro that uses a userform in which a user can enter information about incoming parts. One of the entries in the form is the date on which the part came in which is selected using a pop-up calendar and then stored into a combo box. Once the user types in all of the data properly, the part is entered into an excel sheet.

The only problem that I am having is that you have to press on a date twice (instead of the desired once) in order to be able to press OK. If you only select the date from the calendar once and try pressing OK, the macro crashes for some mysterious reason.

I've been trying to fix this problem for a few days now with no luck. Any ideas?

Thanks a lot,

Rusty
 
In the first user form, in order to select the date you press on a drop button which includes the following code (and once the date is selected it shows in the combo box):

Code from UserForm1:

Private Sub ComboBox1_DropButt*******()
UserForm2.Show
UserForm1.ComboBox1.SetFocus
End Sub

In UserForm2 (the calendar) I included this:

Private Sub Calendar1_Click()

UserForm1.ComboBox1.Text = Calendar1.Value
UserForm2.Hide
End Sub

I followed the code line by line using F8 and for some reason after the date is selected for the first time and you go back to Private Sub ComboBox1_DropButt*******(), when you execute the last line "End Sub", a second combo box seems to appear and when you press on it you are redirected back to Private Sub Calendar1_Click() to click on the date again. If you don't click on the second combo box, the macro seems to go into an infinite loop.

Thanks again,

Rusty
 
Last edited:
Upvote 0
Not necessarely it's just that I wasn't sure if you could use a pop up calendar with a regular text box. Do you think that using a text box might solve the problem?
 
Upvote 0
This seems to work:

Code:
Private Sub TextBox1_Enter()
    UserForm2.Show
End Sub
 
Private Sub Calendar1_Click()
    UserForm1.TextBox1.Text = Calendar1.Value
    Unload Me
End Sub
 
Upvote 0
I just tried it and it works as expected. Thank you!!
Just out of curiosity, what does the line "Unload Me" do?
 
Upvote 0

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