Link to home
Start Free TrialLog in
Avatar of vlovato
vlovato

asked on

Calendars with subforms

Hi

I'm using MSAccess 97.

I have a form which contains a subform that shows lists of appointments made. I want a calendar on my form that when a date is picked the subform will display all the appointments for that date.

Please help!
Avatar of mad3654
mad3654

vlovato,

create a Module named "bascalendar"
Enter the following lines

Option Compare Database
Option Explicit

Const adhcCalendarForm = "frmCalendar"
---------------------------------------------------------
Function adhDoCalendar(Optional varPassedDate As Variant) As Variant
   
       
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz, and Gilbert (Sybex)
    ' Copyright 1997.  All rights reserved.
    '
    Dim varStartDate As Variant


    varStartDate = IIf(IsMissing(varPassedDate), _
    Date, varPassedDate)

    If Not IsDate(varStartDate) Then varStartDate = Date
   DoCmd.OpenForm FormName:=adhcCalendarForm, _
   WindowMode:=acDialog, OpenArgs:=varStartDate
     If isOpen(adhcCalendarForm) Then
        adhDoCalendar = Forms(adhcCalendarForm).Value
        DoCmd.Close acForm, adhcCalendarForm
    Else
        adhDoCalendar = Null
    End If
End Function
---------------------------------------------------------
Put an unbound TxtBox and name it "Date" in the form and make the child link and master link of the subform to the txtbox(Date).
Child Link = date
Master Link = date

I put a button on the form with the following code at the On_Click properties

Private Sub Button_Click()
Me!Date = adhDoCalendar((Me!Date))
End Function

I have a canendar form named "frmcalendar"
When you click the button it opens the form "frmcalendar".
When you click on a date, it updates the "Date" txtbox that is linked to the subform.  This should show you the list of Appts for that date.

Hope this helps
You can try adding an Activex control in the form using the same idea. You won't need the modual.

mad
P.s. I can e-mail this sample data base to you if you wish.


Avatar of vlovato

ASKER

Thanks mad!
Would be grateful if you would email the db to me. Am feeling confused!
(v_lovato@hotmail.com)
V
Avatar of vlovato

ASKER

Thanks mad!
Would be grateful if you would email the db to me. Am feeling confused!
(v_lovato@hotmail.com)
V
ASKER CERTIFIED SOLUTION
Avatar of mad3654
mad3654

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial