I am using 2 active x calendar controls on a form. The user clicks on a
begin date 6/8/08 and an end date 6/14/08. I would like my report to display
this as column headers.
Sun 8,Jun Mon 9,Jun Tues 10, June Ect.... thru Sat 14, June
Can anyone help with this?
Darc
Column headers in the Page Header section?
Add a Form to your database.
Include an unbound control set to a valid date format.
Name this control StartDate.
Add another control as above.
Name this control EndDate.
Add your Calendar control to the form.
Code the Calendar Control's Double-click event to fill the selected
dates into the StartDate control and the EndDate control:
Private Sub objCalendar_DblClick()
Dim ctl As Control
Set ctl = Me!objCalendar
If IsNull([StartDate]) Then
[StartDate] = ctl.Value
Else
[EndDate] = ctl.Value
End If
End Sub
Add a command button to this form.
Code it's Click event:
Me.Visible = False
Next add labels to the Page Header of your report.
Name them, in left to right order, "Label1", "Label2", etc., "Label7"
Set each of these Label control's Tag property to X (No quotes)
Code the Report's Open Event:
DoCmd.OpenForm "frmDates", , , , , acDialog
Code the Report's Close event:
DoCmd.Close acForm, "frmDates"
Code the Report's Report Header Format event:
Dim C As Label
' Clear the old captions
For Each C In Me.Section(3).Controls
If C.Tag = "X" Then
C.Caption = ""
End If
Next C
' Fill in New Captions
Dim SDate As Date
Dim EDate As Date
Dim intX As Integer
SDate = Forms!frmDates!StartDate
EDate = Forms!frmDates!EndDate
For intX = 1 To DateDiff("d", SDate, EDate) + 1
Me("Label" & intX).Caption = Format(SDate, "ddd, dd mmm")
SDate = SDate + 1
Next intX
You should add additional code to the above to limit the number of
days selected to that number of labels you have set up in the Page
header, or less.
Also, I've left any error handling up to you.