Subform - Two questions

Subform - Two questions

Hello,

I'm starting working with subforms and I would like to do two things but I don't know how to do it.

1) On load picklist subform field based on a main form field value

   We have a form with a subform that have 6 rows by default. And there is a picklist in that subform.

   We would like that picklist values were loaded based on other main form field. The main consideration is that we want to that when loading the main form.

How can we do that?

2) Is it possible to create subform lines through scripting?
We have created a form to manage invoices. In that form there is a subform to detail invoice line data.

When creating the invoice we want to create automatically several invoice lines in the subform based on other form data.
How can we do that?

Thanl you very much,

Fidel Martín