Originally Posted by
pkstormy
Here is a new updated (non-api and non-activeX) calendar popup form and subform for MSAccess 2010 which you can utilize in your existing programs. If you are converting from 2003 or prior, you'll note that the Calendar activeX control is no longer supported (you'll need to remove it in all your forms as well as in the References). You then have the option of using the (new) DatePicker built into any date defined data fields (you can disable this by selecting "Never" for the "Show Date Picker" property of the control - 8th property down when the All tab is selected.) Otherwise if this is set to "For Dates" (which it defaults to), you'll see a small calendar icon to the right of the control when the field has focus or is clicked on. The DatePicker control is fairly limited on navigating versus the old activeX Calendar Control but you may be able to customize it somehow. (I have yet to figure out why MS didn't build a better Calendar Control replacement versus the DatePicker. I was also surprised that there was no conversion. I had to manually remove the old Calendar Control and coding everywhere throughout the project.)
To use either the popup calendar or subform in the attached, you only need to import the form called: CalendarPopUp or SubCalendar form into your *.accdb file (all the code/functions are contained within the forms - ie. you don't need to set any additional references, load any activeX components, or register any dll files, etc!!) I designed this so it could quickly be implemented into any existing or new design. This version has all MSAccess 2010 buttons for the dates versus the old version I posted which had 2000 buttons.
For example, to open the popup calendar, you would add code in your event such as:
Private Sub cmdCalBirthDate_Click()
Me.BirthDate.SetFocus
DoCmd.OpenForm "CalendarPopUp"
Forms!CalendarPopUp!vFormName = "frmExamplePersons"
Forms!CalendarPopUp!vFieldName = "BirthDate"
End Sub
That's it. The CalendarPopUp form does the rest. In the subform if you want to make it interactive whenever a date is clicked on (versus using the "Use Selected Date" button), you would add any code you want to fire (when a date is clicked on) in the: FireOffDateValue function.
Fixed on both forms:
Fixed is clicking the prev or next arrow buttons (when the 1st day of the month or last day of the month is selected) will now go to the prev or next month versus a message box saying "At the beginning of the month" or "At the end of the month".
CalendarPopUp form:
Fixed when popup form opens it goes to the date field value (where the SetFocus command was set to prior to the openform code).