Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Long, Crystal
  New Posts New Posts RSS Feed - Calendar Subform(s)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)

Calendar Subform(s)

 Post Reply Post Reply
Crystal Long View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 21 May 2012
Location: Colorado
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crystal Long Quote  Post ReplyReply Direct Link To This Post Topic: Calendar Subform(s)
    Posted: 20 Jan 2013 at 2:42am

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 ~
Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down