Forum Discussion

TheBams's avatar
TheBams
Copper Contributor
Oct 02, 2023

Showing image in a userform from another userform

In a userform, I will select one product (of 300+), and a image appear... and I have all pictures put in another userform and multipages (can't use a folder as this have to be shipped to and from different computers and people).
In my userform I can make the correct path to the image visible (chained together by the selections made) in a textbox, but can't make this a working path. can anywone point out the obvious errors I making 😉 ?
 
The code/example:

Private Sub TextBox1_Change()
'TextBox2.Value = ("MultiPage1." & "Page2." & "Image3" & ".Picture")

'The value in textbox2, is based on some selections in the userform and/or cells in sheet, so the page/image names
'changes due to different selections, but for the short version this will be the same principle....wouldn't it?

'WORKS - - - But have to make 350 if's ;-(
'If TextBox1 = 1 Then
'Image2.Picture = MultiPage1.Page1.Image1.Picture '(from userform1)
'Else
'Image2.Picture = UserForm2.MultiPage1.Page2.Image3.Picture

'End If

End Sub

Or are there any better ways? 

1 Reply

  • JKPieterse's avatar
    JKPieterse
    Silver Contributor
    I think:
    Forms("UserForm2").Controls("MultiPage1").Pages("Page2").Controls("Image3").Picture
    But it is too much work to try to create a testing form just to answer this question.

Resources