Inserting new master record + detail records at same time

I have master\detail forms that work fine when editing\viewing existing master\details records.

But adding a new record in a master form, the detail form is not shown (I guess because the linking field is not populated yet in the master form).

Is there any way to enter both the new master record and its details records from the same page (like when editing\viewing)?

If you have master_id linked with Detail, like:

MASTER_TABLE
master_id
some_other_fields

DETAIL_TABLE
detail_id
master_id
some_other_fileds

Then you have to have master first, like you said - linking fileds has to be populated first in master form. But it can be done with some coding also that it works like you want.