I have a main form with a subform that loads image records. When I set up the forms I specified the control source for the image box on the subform itself through the properties with the following:
=[Forms]![MainForm]![cmbImageLocation] & [RelativePath] & [ImageFileName]
Where cmbImageLocation
is a combobox on the main form with a root directory, and RelativePath
is the folder location and ImageFileName
is the specific jpeg file.
An example would be:cmbImageLocation
D:\RelativePath
OneDrive\ImageFileName
001.jpg
The complete concatenated path would be D:\OneDrive\001.jpg
If this code is used in the image box subform control source, the picture loads successfully.
I now need to move the control source specification from the subform to the main form's VBA.
I set up a test textbox in the subform and ran this code in the main form's VBA:
Me.subFormImages!txtTest.ControlSource = "=[Forms]![MainForm]![cmbImageLocation] & [RelativePath] & [ImageFileName]"
I get the proper string D:\OneDrive\001.jpg
If I use the same code to update the image box control source on the subform:
Me.subFormImages!ImgBox.ControlSource = "=[Forms]![MainForm]![cmbImageLocation] & [RelativePath] & [ImageFileName]"
I get
"Run Time error '438': Object doesn't support this property or method".