Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding pop-up calendar to Outlook 2003 custom form 1

Status
Not open for further replies.

dunkster

Technical User
Jan 23, 2003
14
AU
I am new to Outlook Forms programming.
What VBA code do I need and where do I include it, to have a Pop-up Calendar set on a date field in an Outlook custom form I have created.
 
You need to add the Calendar Control to the userform. Right click on the Toolbox and select Additional Controls.
 
I have the calendar on the form now. When I bind the Date field to the Calendar on the Properties screen it does not activate the Calendar.
 
Assuming the calendar is in UserForm1, the VBA code would be:

UserForm1.Show

And when you want to hide the calendar:

UserForm1.Hide

To free the memory:

Unload UserForm1
 
does this code go in "ThisOutlookSession" or in "Module" ?
 
Unless it has to be in "ThisOutlookSession" I put it in a module. For example the Application_Startup event has to be in "ThisOutlookSession".

From your first post it sounds like you have a userform to be filled out that has a field for a date. You want the user to be able to select the date from the calendar. Is that correct?
 
On the first userform (call it UserForm1) place a button (call it CommandButton1) that the user will press to call up the calendar.
Code:
Option Explicit

Dim dDate As Date ' Used to store date returned from Calendar

Private Sub CommandButton1_Click()
UserForm2.Show
' Sets the variable dDate equal to the selected date
dDate = UserForm2.dUserDate

' Free memory
Unload UserForm2
End Sub

UserForm2 will be the calendar.
Code:
Option Explicit

Dim dSelectedDate As Date ' Date selected by user

Property Get dUserDate()
dUserDate = dSelectedDate
End Property

Sub Calendar1_Click()
dSelectedDate = Calendar1.Value
UserForm2.Hide
End Sub

Private Sub UserForm_Initialize()
' Initializes the calendar control to todays date
Calendar1.Value = Date
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top