Results 1 to 3 of 3

Thread: [RESOLVED] Populating linked form field with parent form primary key

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    Resolved [RESOLVED] Populating linked form field with parent form primary key

    I am developing a form in Access which needs to have a linked form (rather than a subform), but it needs to be connected to the parent form by a foreign key. My problem is basically this, when I click the button on the parent form to filter the child form by primary key this works fine. But if there is no record available and the user wants to add one I want the foreign key on the child form to be automatically populated with the primary key from the parent form.

    I have done this easily enough with a subform, does anyone know how I can achieve the same thing with a linked form?

    Thanks for any help anyone can offer.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Populating linked form field with parent form primary key

    uhhh. If you are opening a form, you can pass OpenArgs property. Then on the form that is opened you can use the OnOpen/OnLoad Event(s) to fill as required.

    Or you use
    Code:
    Forms("<formname>").Controls("<controlname>") = <value>
    Once the child (linked) form has been opened from the parent form.

    Does this help?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    Re: [RESOLVED] Populating linked form field with parent form primary key

    Thanks. In the end I set the controls default property to the value on the parent form and then locked the control so the user could not change.

Posting Permissions

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



Click Here to Expand Forum to Full Width