Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Subform linking fields headache (2000sp3)

    I have a set of subforms I reuse with many different forms. I am working on one form where I need the subforms to be based on different tables depending on a value entered on the main form. I have ensured that the child fields in both of these tables have identical names, data types and sizes. When I set the recordsource of the subform's form in code, however, the linking fields are reset to the primary keys of the tables underlying the main form and subform. This is the case even if the subform's recordsource is being set to that originally specified in the subform's form's design. When I try and change the subform's linkmasterfields and linkchildfields in code, Access complains because I am using a different number of fields - of course, as I cannot change the master and child fields at the same time, so there will be a nanosecond where they are incompatible. I'm not even sure if this is possible even without this problem, as online help says these properties can only be set in design view and in the onopen event.

    Can anyone suggest a workaround? I cannot change the primary keys of these tables, as that would create havoc, and I don't want to create two different subforms and make the appropriate one visible as that would require recoding a lot of (main)forms.

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subform linking fields headache (2000sp3)

    Try clearing the LinkMasterFields and LinkChildFields properties by setting them both to "" (an empty string) first, before setting them to the new values.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Subform linking fields headache (2000sp3)

    Thanks Hans, worked a treat. I love simple answers.

    So online help appears to be wrong in saying these properties can only be set in design view and onopen. Have to say I'm glad that's the case!

    Cheers once more

Posting Permissions

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