Foreign Key Insert - automatically

I have Grid A with a link that opens Grid B and is filtered on Grid A’s primary key. Grid B has a link to Form B. When I insert a new record into Form B, the foreign key (Grid A PK) is blank.

How do I automatically fill in the foreign key on insert in Form B?

I think you need the onbeforeinsert event and put some custom code there to insert the master pk.

Thank you for your reply. That’s a step in the right direction (for my understanding), but what code might I put there?

BTW: Once I do this the first time, I will be able to apply it in many similar situations.

If you go into the event you have a bunch of code snippets on the right, one of them is insert data into another dataset. It will pre-generate a template containing an insert statement. In general, just use the scriptcase macro’s to perform an insert into your master table.

Thanks for your help.

This turned out to be easy to do. See image…

But I have no idea how or where I set the variable [vProject_Id]? [ATTACH=CONFIG]n73735[/ATTACH]