I have a main form with a "master" combo box, and on this form there is a subform with a dependent combo box. When I select a value in the master combo box, the values in the dependent combo box are filtered correctly. Everything works fine, but I would like to re-use the same subform in different main forms.
In the row source property of the dependent combo box (in the subform), I have specified the name of the main form:
[Forms]![frmQuoteAdd]![CustID]
Since "Me" is not allowed in this context (guessing from the error messages I get), I have created a variable that contains the name of the main form in the subform's Form_Open event.
Dim strFormName As String
strFormName = Me.Parent.Name
MsgBox strFormName
When the main form opens, the message box displays the name of the main form correctly, so I'm assuming this variable is recognized by the subform.
My question is, can I replace the absolute name of the main form (frmQuoteAdd) with the variable "strFromName" in the criteria of the dependent combo box? I have tried all kinds of syntax variations, but to no avail.
(I have tried other more "sophisticated" approaches with public functions using "frm As Form" as an argument, etc., but in the end, the problem is always getting Access to interpret the variable in the dependent combo box criteria.)
Thank you in advance for any help, which would be greatly appreciated.
In the row source property of the dependent combo box (in the subform), I have specified the name of the main form:
[Forms]![frmQuoteAdd]![CustID]
Since "Me" is not allowed in this context (guessing from the error messages I get), I have created a variable that contains the name of the main form in the subform's Form_Open event.
Dim strFormName As String
strFormName = Me.Parent.Name
MsgBox strFormName
When the main form opens, the message box displays the name of the main form correctly, so I'm assuming this variable is recognized by the subform.
My question is, can I replace the absolute name of the main form (frmQuoteAdd) with the variable "strFromName" in the criteria of the dependent combo box? I have tried all kinds of syntax variations, but to no avail.
(I have tried other more "sophisticated" approaches with public functions using "frm As Form" as an argument, etc., but in the end, the problem is always getting Access to interpret the variable in the dependent combo box criteria.)
Thank you in advance for any help, which would be greatly appreciated.