Solved Issues filling primary key of new record in related table

May 25, 2015 at 10:51:20
Specs: Windows 7, 2.1 GHz / 4063 MB
I have an access form with button to open a form to add new entities to a table with related data. When this form is opened, I would like the primary key of that new entity that is being added to be autofilled with the primary key of the record that was open on the form where the user clicked the button to open the new form... if that makes sense?

I have the table that related entities may be added to as a "locked" datasheet view subform on my main form. When I clock the "modify button, I want to the user to be able to add new records via a different more user friendly form. When adding new records, however, an error massage is shown stating that the "primary key" can not contain a null value.

This doesn't seem to occur if I leave the datasheet view subform as unlocked though. Can anybody help?


Can I put a question here?

See More: Issues filling primary key of new record in related table

Report •

May 26, 2015 at 05:06:29
✔ Best Answer
I'm not sure I'm supposed to answer my own questions, but:

In the "Click()" function for the button:

DoCmd.OpenForm "FormName", acNormal, "", "", , acNormal, Me.IDToPass

and, in the form that is being opened's "Current()" function:

Me.IDToSet.Value = Form.OpenArgs

Hope this can help somebody else!

Can I put a question here?

Report •

May 26, 2015 at 08:05:14
Quite OK to answer your own question and to give it Best Answer if that applies. As you say, it could help others.

Always pop back and let us know the outcome - thanks

Report •
Related Solutions

Ask Question