Results 1 to 5 of 5
  1. #1
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60

    Main form and subform

    In my database, I have an "Event" form that contains an "Activities" subform. Each Event can have several activities associated with it. Here is what I want to do:

    When all the "Activities" in an Event have an "ActivityStatus" of "Closed", I want the "EventClosed" checkbox on the Main Event form to auto check.

    I have attached a sample database. The Main Menu will allow you to select a "New Event" which opens a blank Event form ready for a new entry or you can select "Event List" which will open up a list of already created Events and allow you to open that Event for edits.

    Any help is much appreciated!

    Thanks!
    Attached Files Attached Files

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Using an AfterUpdateEvent of your criteria, you can do something like,
    If Me.ActivityStatus = "Closed" Then Me.[MyCheckBox] = True
    HTH

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    I would say you need a routine say: CheckEventClosed()
    it would go on the form_oncurrent event, and subform_afterupdate event

    have 2 'invisible' text boxes that count the sub form query
    1 to count closed records (linked to the master key)
    1 to count all records (linked to the master key)

    txtClosedCount = dcount("*",qsSubFormClosed)
    txtAllCount= dcount("*",qsSubFormAll)

    'this event will run when you change record, or update the sub form.
    Code:
    sub  CheckEventClosed()
       chkEventclosed.value = txtClosedCount = txtAllCount
    end sub

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    In the AfterUpdate event of the ActivityStatus control of the subform, add this code:


    Code:
    Private Sub ActivityStatus_AfterUpdate()
      If Me![ActivityStatus] = "open" Then
        Me.Parent![EventClosed] = False
      Else
        If Me.Dirty Then Me.Dirty = False
        If DCount("*", "sfrmActivities", "eventID = " & Me.Parent![EventID] & " AND ActivityStatus = ""Open"" ") = 0 Then Me.Parent![EventClosed] = True
      End If
    
    End Sub
    I tried it and it works on the test DB

    HTH

    John

  5. #5
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    John,

    Thank you! This did the trick!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Get Sum of Column X of Subform in Main Form
    By adnanebrahimi in forum Forms
    Replies: 9
    Last Post: 09-21-2012, 08:58 AM
  2. Replies: 3
    Last Post: 04-17-2012, 10:28 AM
  3. Totals from subform to main form
    By kathi2005 in forum Forms
    Replies: 4
    Last Post: 11-04-2011, 10:19 AM
  4. Controlling Subform from Main Form
    By SteveF in forum Forms
    Replies: 5
    Last Post: 07-01-2011, 05:32 PM
  5. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums