Hello,
My problem is how to refer to a control on a subform in the following situation:
I have mainform/subform, with a combo box on the subform. If you enter a name in the combo and it isn't present, then a new account form opens, the name you typed is entered into a new account record, then you add other info. When you close the new account form, a proceedure carries back the new account record number to put it into the combo box and requery the box to show the name.
If I explicitly refer to the subform and control the procedure works fine:
Forms![Mainform]![Subform]![BatchID] = varBatchID
Forms![Mainform]![Subform]![cboBatch].Requery
I want to use this procedure on several different mainforms with different names (the subform name never changes), so I need to set the mainform name to the current form name and use this as I did above. I have tried setting a variable to Screen.ActiveForm or Screen.ActiveForm.Name and substituting the variable into the above code, but Access never recognizes the form I'm trying to refer to. I have tried using the command Forms("strvariable"
but I haven't got that right, either:
strForm = "[Screen].[ActiveForm].Name"
Forms("strForm"
![Subform].[BatchID] = varBatchID
I would really appreciate any guidance on how to code this correctly.
Thank you!!
-Tom
My problem is how to refer to a control on a subform in the following situation:
I have mainform/subform, with a combo box on the subform. If you enter a name in the combo and it isn't present, then a new account form opens, the name you typed is entered into a new account record, then you add other info. When you close the new account form, a proceedure carries back the new account record number to put it into the combo box and requery the box to show the name.
If I explicitly refer to the subform and control the procedure works fine:
Forms![Mainform]![Subform]![BatchID] = varBatchID
Forms![Mainform]![Subform]![cboBatch].Requery
I want to use this procedure on several different mainforms with different names (the subform name never changes), so I need to set the mainform name to the current form name and use this as I did above. I have tried setting a variable to Screen.ActiveForm or Screen.ActiveForm.Name and substituting the variable into the above code, but Access never recognizes the form I'm trying to refer to. I have tried using the command Forms("strvariable"
strForm = "[Screen].[ActiveForm].Name"
Forms("strForm"
I would really appreciate any guidance on how to code this correctly.
Thank you!!
-Tom