Print Page | Close Window

Calendar Subform(s)

Printed From: Roger's Access Library
Category: Other Download Libraries
Forum Name: Long, Crystal
Forum Description: Access Basics is designed for those of you with a thirst to understand the fundamentals of Access with programming in mind ... whether you realize it or not.
Printed Date: 20 Mar 2019 at 10:43pm

Topic: Calendar Subform(s)
Posted By: Crystal Long
Subject: Calendar Subform(s)
Date Posted: 20 Jan 2013 at 2:42am

download: - uploads/84/
explodes into Access 2007 database

This is a subform version of the popup calendar located here: -

oftentimes, you want to put a calendar on a form as a subform -- or maybe more than one!  This example uses one subform multiple times. 


Synchronizing the calendar subform to the proper textbox control is made easier by naming the controls like this:



you can. of course, name them however you like!

the Load event of the mainform sets each respective subform:

   Dim i As Integer
   For i = 1 To 3
      With Me("Calendar" & i).Form
         If Not IsNull(Me("Date" & i)) Then
            .Set_Calendar Me("Date" & i)
            .Set_Calendar Date
         End If
         .Label_LinkControlname.Caption = "Date" & i
      End With
   Next i

The key to this working is a public function behind the calendar form called Set_Calendar that takes a date as a parameter.

Label_LinkControlname is a hidden control on the subform that holds the name of the control on the main form to set when the calendar is changed

the AfterUpdate event of each date textbox on the mainform calls code behind the subform to change the calendar, for example:

Private Sub Date1_AfterUpdate()
   If IsNull(Me.ActiveControl) Then Exit Sub
   Me.Calendar1.Form.Set_Calendar Me.Date1
End Sub

Warm Regards,

Microsoft MVP
remote programming and training

Access Basics by Crystal -
Free 100-page book that covers essentials in Access - -

   (: have an awesome day :)

Warm Regards,
Microsoft MVP
Remote Training & Programming
Let's Connect and Build Together
~have an awesome day ~

Print Page | Close Window