Calendar in User Form

J

Joanne

Hello,
I have a user form on which I'd like to add a text box where a date will be
entered. At the end of the text box, I'd like to have a drop down or
something like it that will be a calendar so the user can pick the date and
the date will be enterd in the text box. Then the value of the text box will
be enteredin the header of my document. I know how to use the calendar
control but it seems like I have to create a separate user form for the
control and I don't know how to integrate this with my existing user form.
Thanks in advance for any help you can provide.
 
D

Doug Robbins - Word MVP

Is you "user form" really a UserForm or is it a document that contains
FormFields?

With a real UserForm, you can add a Calendar Control onto the form itself
and have the selected date appear in a textbox on the form if need be.

Assuming that the Calendar control has the name of Calendar1 and that you
have a textbox with the name of txtDate, the following code will cause
whatever data is selected on the calendar to appear in the textbox: in the
format shown.

Private Sub Calendar1_Click()
txtDate.Text = Format(Calendar1, "d MMMM yyyy")
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Joanne

Thank you very much. That worked great.

Doug Robbins - Word MVP said:
Is you "user form" really a UserForm or is it a document that contains
FormFields?

With a real UserForm, you can add a Calendar Control onto the form itself
and have the selected date appear in a textbox on the form if need be.

Assuming that the Calendar control has the name of Calendar1 and that you
have a textbox with the name of txtDate, the following code will cause
whatever data is selected on the calendar to appear in the textbox: in the
format shown.

Private Sub Calendar1_Click()
txtDate.Text = Format(Calendar1, "d MMMM yyyy")
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top