Calendar control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to select a range of dates from a calendar control to populate
a form?

Thanks
 
AFAIK it can't be done with Microsoft's standard Calendar or DTPicker.
Perhaps there are third party calendars out there capable of doing this(?).
What you can do, though, with Microssoft's standard controls, is either use
two in order to have a From and a To date for your criteria, or use a single
one, unbound, just for date selection, so feed two textboxes on a form to
serve as the From and To boundaries. A few lines of code would do it. Here's
an example, assuming:
* two text controls clled txtDateFm and txtDateTo
* an activeX calendar called ActiveXCtl1
* a Public variable called "caller: to store the name of the textbox calling
the control
The calendar control is hidden (Visible = No) in the form's design, and is
positioned right under the calling textbox and made visible by the txtbox's
double click (or click, enter, got focus... event):

Option Compare Database
Public caller As String

Private Sub ActiveXCtl1_Click()
Me.Controls(caller) = Me.ActiveXCtl1
Me.Controls(caller).SetFocus
Me.ActiveXCtl1.Visible = False
End Sub

Private Sub txtDateFm_Click()
caller = Me.ActiveControl.Name
Me.ActiveXCtl1 = Date
Me.ActiveXCtl1.Top = Me.txtDateFm.Top + Me.txtDateFm.Height + 15
Me.ActiveXCtl1.Left = Me.txtDateFm.Left
Me.ActiveXCtl1.Visible = True
End Sub

Private Sub txtDateTo_Click()
caller = Me.ActiveControl.Name
Me.ActiveXCtl1 = Date
Me.ActiveXCtl1.Top = Me.txtDateTo.Top + Me.txtDateTo.Height + 15
Me.ActiveXCtl1.Left = Me.txtDateTo.Left
Me.ActiveXCtl1.Visible = True
End Sub

HTH,
Nikos
 
The MS MonthView Calendar control does support the selection of a
continuous range of dates.

Instead of using an ActiveX control though see:
http://www.lebans.com/monthcalendar.htm
A97MonthCalendar.zip is an A97 database containing a Class that wraps
the Microsoft Month Calendar Common Control in an easy to use interface.

A2K Version here: MonthCalendar Access 2000.zip

This is a completely API generated Month Calendar derived directly from
the Common Control DLL.

What this means is that there are no distribution or versioning issues
as there are if you use the ActiveX Month Calendar control. In other
words this is not an ActiveX control!

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top