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.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=609
Printed Date: 17 Dec 2017 at 4:56am


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

download:
http://www.rogersaccesslibrary.com/forum/uploads/84/Calendar_Subform_Crystal_130119_ACCDB_.zip - uploads/84/Calendar_Subform_Crystal_130119_ACCDB_.zip
explodes into Access 2007 database

This is a subform version of the popup calendar located here:
http://www.RogersAccessLibrary.com/forum/popup-calendar-for-access-2007-and-above_topic597.html - http://www.RogersAccessLibrary.com/forum/popup-calendar-for-access-2007-and-above_topic597.html

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. 

Calendar_Sub.jpg

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

Date1
Date2
Date3

Calendar1
Calendar2
Calendar3

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)
         Else
            .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()
'130119
   If IsNull(Me.ActiveControl) Then Exit Sub
   Me.Calendar1.Form.Set_Calendar Me.Date1
End Sub


Warm Regards,
Crystal

Microsoft MVP
remote programming and training

Access Basics by Crystal
http://www.AccessMVP.com/strive4peace - http://www.AccessMVP.com/strive4peace
Free 100-page book that covers essentials in Access

http://www.YouTube.com/LearnAccessByCrystal - http://www.YouTube.com/LearnAccessByCrystal

http://www.MsAccessGurus.com - http://www.MsAccessGurus.com

 *
   (: have an awesome day :)
 *



-------------
Warm Regards,
Crystal
Microsoft MVP
Remote Training & Programming
Let's Connect and Build Together

http://www.AccessMVP.com/strive4peace
http://YouTube.com/LearnAccessByCrystal
~have an awesome day ~



Print Page | Close Window