PDA

Click to See Complete Forum and Search --> : [RESOLVED] Populating linked form field with parent form primary key


Santos7772005
May 7th, 2006, 06:33 PM
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.

Ecniv
May 9th, 2006, 03:33 AM
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

Forms("<formname>").Controls("<controlname>") = <value>

Once the child (linked) form has been opened from the parent form.

Does this help?

Santos7772005
May 9th, 2006, 06:12 PM
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.