I've got a form and a button on it. I would like to open another form on a button click with a parameter passed from the parent form to the child form (child form's RecordSource has parameters). How can I do it?
If the parent form is open, you can do the following
Form!MyParentForm!myPublicVariableOfParentForm
There could be other ways, whereby you can call a method on the child form with a parameter from the parent form.
You can use "OpenArgs". When calling a form just pass your OpenArgs string and on the child form read it and parse. It's up to you to prepare custom solution to build an parse more sophisticated "OpenArgs" strings. Refer: http://msdn.microsoft.com/en-us/library/bb215912.aspx
You can refer to any property of the calling form by reference to the form's object. I will not use the ! notation for form's properties (I hate it). so if you want to inherit:
a form's control value:
forms(parentFormName).controls(controlName).value
a form's recordset field value:
forms(parentFormName).recordset.fields(fieldName).value
The recordset turnaround is particularly useful when accessing id's (guid) values. You cannot read these values through form's controls, but you can access them throught the corresponding field in the recordset. If you have a combobox on a form containing a guid field, please compare the following:
screen.activeForm.controls(myComboControlName).value
and
screen.activeForm.recordset.fields(myComboControlName).value