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

>
Want a good read? Try The Summer of His Life (available on Amazon!)

Calendar Subform(s)

 Post Reply Post Reply
Author
Message
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

download:
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

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
Free 100-page book that covers essentials in Access

http://www.YouTube.com/LearnAccessByCrystal

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 ~
Back to Top
Sponsored Links
>
Want a good read? Try The Summer of His Life (available on Amazon!)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.