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?
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
If the parent form is open, you can do the following
Forms!MyParentForm!myPublicVariableOfParentForm
There could be other ways, whereby you can call a method on the child form with a parameter from the parent form. Remember the control will likely need focus before being manipulated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With