Results 1 to 4 of 4
  1. #1
    kalltim is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Long Beach, CA
    Posts
    5

    OpenForm for those parent records having chidren

    Access novice needs help! I am sure there is a way to do this. I am wanting to open a form (docmd.openform) where I see only those parent records which has a matching child record. In plain english I am wanting to see only those students [student info] who have come in for an advising appointment [student advising]


    My two tables are [student info] and [student advising].
    Tables are related in a one [student info] to many [student advising] relationship. Both tables are linked on field [student id]

    [Advising Appointment] form has a subform (the many side of the relationship) of [Student Advising subform]

    This is what I have tried so far to no avail-

    Private Sub Command1_Click()
    On Error GoTo SearchRout_Err
    ‘the check box (check20) gets checked if I want to see only students who have been in for advising
    If Check20 = True Then
    DoCmd.OpenForm "Advising Appointment", acNormal, "", "[Student Advising subform]![Student Advising]![Student ID] Is Not Null"
    Else
    DoCmd.OpenForm "Advising Appointment", acNormal, ""

    End If
    SearchRout_Exit:
    Exit Sub
    SearchRout_Err:
    MsgBox Error$
    Resume SearchRout_Exit
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    One way is to have a field constructed in the main form RecordSource with an expression that checks the appointment table for records, like:

    HasAppt: DLookup("StudentID","Appointment","StudentID=" & [StudentID])

    Then use that field as criteria in the WHERE clause:
    DoCmd.OpenForm "Advising Appointment", acNormal, "", "HasAppt Is Not Null"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    kalltim is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Long Beach, CA
    Posts
    5
    Quote Originally Posted by June7 View Post
    One way is to have a field constructed in the main form RecordSource with an expression that checks the appointment table for records, like:

    HasAppt: DLookup("StudentID","Appointment","StudentID=" & [StudentID])

    Then use that field as criteria in the WHERE clause:
    DoCmd.OpenForm "Advising Appointment", acNormal, "", "HasAppt Is Not Null"
    Okay- I think I understand your solution. In my master form I need to create a field that looks at the subform and checks to see if a matching student ID is found. If it finds one then the new field gets updated with the ID and if not it results in a Null.

    Then I do my openform request, testing on this new field.

    So essentially I can only filter records based on a parent field and not a child field?

    Will give it a whirl.

    Thanks for your input!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Child cannot command the parent. The subform 'piggy-backs'. So, yes, filter the main form and subform will synchronize.

    Technically, the DLookup is not checking the subform because it isn't even open yet. The check is directly on the table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  2. Getting to a tab on openform
    By Swarland in forum Programming
    Replies: 5
    Last Post: 12-12-2010, 11:22 AM
  3. Delete child records with parent record
    By jpkeller55 in forum Access
    Replies: 8
    Last Post: 09-07-2010, 08:52 PM
  4. OpenForm macro
    By tguckien in forum Forms
    Replies: 3
    Last Post: 07-06-2010, 09:12 AM
  5. Passing Data with OpenForm
    By nkenney in forum Forms
    Replies: 1
    Last Post: 10-26-2009, 11:40 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