Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Kendrick, Idaho, USA
    Posts
    277
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Open to specific record (2000)

    I know I can open a form to a desired record by setting the stLinkCriteria argument in a DoCmd.OpenForm command. If the form has a subform, how can I also specify the record to be displayed in the subform? In other words, the subform displays the child records that link to the record in the main form - I want to specify which child is seen.
    Thanks

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Open to specific record (2000)

    You can do essentially the same thing by applying a filter to the subform and turning on the filter. Of course you have to know which record you want to view, and in general subforms are designed to show multiple records, so that can be a challenge. It must of course be done in code, and usually involves setting the FilterOn property to True. If you know what the Filter should look like in advance, you can set it at design time for the subform. Otherwise you will also need to set the value of the filter in code when you open the main form. Hope this helps.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Open to specific record (2000)

    If the subform is properly linked to the parent form, then all the records you see in the subform are the "right" records. If you want a specific subform record, how would you determine which one it should be? If it's an issue like latest date, etc., you can simply order the query behind the subform to sort in that order. Then the link between the parent and subform will take care of which records are displayed and the query will take care of the order they're displayed in.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •