I'm stuck. I have a product table and in it, a field called product_form. Each product has its own form to be displayed as a subform on a main order form.
I want to dynamically assign the subform at load time for the product selected.
In the Form Load event I have:
form_name = DLookup("product_form", "tListProds", "id = " & Me.product_id)
' ** This returns a value like: "fProdDoors" or "fProdGates"
I also have the following in the Form Load event:
Debug.Print "The source is: " & Forms("fOrderProductMain").Form.Controls("ProductSubForm").SourceObject
Debug.Print "The short source is: " & Me!ProductSubForm.SourceObject
' ** I put in the debug statements to make sure I was referencing the control the correct way. Both show the default sourceobject of fProdDoors. I've tried removing the default sourceobject, but then the references give me an error that the control can't be found (and I didn't delete the subform container - just the text from the sourceobject property)
I've tried
Me!ProductSubForm.SourceObject = form_name
'** this gives a Runtime 2101 - the setting isn't valid for this property
And
Me!ProductSubForm.SourceObject = Eval(form_name)
'** this gives a Runtime 2482 - Can't find the name "fProdDoors"
Shouldn't I be able to dynamically assign the SourceObject at load time? And use a variable to hold the name of the SourceObject? Is it thinking that I'm trying to feed it a query name?
I want to dynamically assign the subform at load time for the product selected.
In the Form Load event I have:
form_name = DLookup("product_form", "tListProds", "id = " & Me.product_id)
' ** This returns a value like: "fProdDoors" or "fProdGates"
I also have the following in the Form Load event:
Debug.Print "The source is: " & Forms("fOrderProductMain").Form.Controls("ProductSubForm").SourceObject
Debug.Print "The short source is: " & Me!ProductSubForm.SourceObject
' ** I put in the debug statements to make sure I was referencing the control the correct way. Both show the default sourceobject of fProdDoors. I've tried removing the default sourceobject, but then the references give me an error that the control can't be found (and I didn't delete the subform container - just the text from the sourceobject property)
I've tried
Me!ProductSubForm.SourceObject = form_name
'** this gives a Runtime 2101 - the setting isn't valid for this property
And
Me!ProductSubForm.SourceObject = Eval(form_name)
'** this gives a Runtime 2482 - Can't find the name "fProdDoors"
Shouldn't I be able to dynamically assign the SourceObject at load time? And use a variable to hold the name of the SourceObject? Is it thinking that I'm trying to feed it a query name?