Dan Waters
dwaters at usinternet.com
Mon Jun 23 09:04:09 CDT 2008
Hello to Everyone! Last week I learned how to use Stephen Lebans' date selection calendar. This is not an ActiveX control, but uses API calls. If you haven't looked at this calendar you should. It's quite versatile and is user-configurable. For my customers' use I often record short tutorial videos. If you'd like to view the video I made for this Calendar, you can go to http://www.promationsystems.com/demo.htm. The link is at the bottom of the page. The video is in WMV format, is about 11 minutes long, and goes through all the features. I also may have 'stumbled' across a way of using this on a subform. Instead of instantiating the class (clsMonthCal) in the form as per the instructions on Lebans' site, I instantiated this in a standard module (thanks to Lambert and Charlotte!). I'm posting the code to do this below: '-------------------------------------- '-- In a form or subform (I have only tried a 1st level subform) Private Sub butGetDates_Click() '-- The End Date is optional but is needed if you want a date range. '-- Pass the complete reference to the date controls so that _ the standard module can write back to them. Call OpenCalendar(Forms("frmMain")("txtStartDate"), Me.hWnd, Forms("frmMain")("txtEndDate")) End Sub '-------------------------------------- '-- In a standard module '-- Get the example .mdb from Lebans' site. _ It contains the class module (clsMonthCal) and 4 standard modules. _ Instructions are on the page for this Calendar. Private mc As clsMonthCal Public Sub OpenCalendar(txtStartDateOnForm As TextBox, lnghwnd As Long, Optional txtEndDateOnForm As TextBox) Dim blnRet As Boolean Dim dteStart As Date Dim dteEnd As Date '-- Create an instance of our Class Set mc = New clsMonthCal '-- Set the hWndForm Property mc.hWndForm = lnghwnd '-- Date fields are typically empty to start with dteStart = Nz(txtStartDateOnForm, 0) dteEnd = 0 '-- Run the calendar. The calendar is modal during this line blnRet = ShowMonthCalendar(mc, dteStart, dteEnd) If blnRet = True Then txtStartDateOnForm = dteStart If Not txtEndDateOnForm Is Nothing Then txtEndDateOnForm = dteEnd End If Else '-- Add any message here if you want to _ inform the user that no date was selected End If End Sub '----------------------------- Perhaps someone will find this to be helpful! Dan