VBA: Addressing between userforms

L

Legacy 143009

Guest
Hi Guys!

My question is very short but I couldn't solve it.
I have a Johnjpg1 image in Form1. And at the end of my worksheet Sub Module it shows Form2.

Code:
If A1="John 01" Then
Display  From1\Johnjpg1 in Form2\Frame1

Thanks a lot!
 
Last edited by a moderator:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I doesn't have to be clickable. Even it's better if it is not clickable. I just wanna use it like an image result pop up.
 
Upvote 0
Hi again,

Why not just load the image into the control on form2?
i.e.,
Load UserForm2 - this gives you access to the forms controls.
Populate the image control.
Show UserForm2

Code:
[COLOR=darkblue]Sub[/COLOR] test()
   [COLOR=darkblue]If[/COLOR] UCase(Sheets("Sheet1").Range("A1").Value) = "JOHN" [COLOR=darkblue]Then[/COLOR]
      Load UserForm2
      UserForm2.Image1.Picture = LoadPicture("[COLOR=#ff0000]C:\My Pictures\1111.jpg[/COLOR]")
      UserForm2.Show
   [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
End [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0
Yes bertie, in fact you are right. I thought about this but I don't want to stay bind with a directory address. If there is a way to show parent address it suits me fine. Because the project file and the pictures are in the same directory.

BTW, it is not going to call image into form, also in a specific frame in the form.
 
Last edited by a moderator:
Upvote 0
Edit as highlighted:
Code:
[COLOR=darkblue]Sub[/COLOR] test()
   [COLOR=darkblue]If[/COLOR] UCase(Sheets("Sheet1").Range("A1").Value) = "JOHN" [COLOR=darkblue]Then[/COLOR]
      Load UserForm2
      UserForm2.Image1.Picture = LoadPicture([COLOR=#ff0000]ThisWorkbook.Path [/COLOR]& "\1111.jpg")
      UserForm2.Show
   [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
End [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0
Ummm... Not to call in a frame but in a image field. :) Clever ;) This works for me. Thanks again bertie! ;)
 
Last edited by a moderator:
Upvote 0
Ow, ow ow, I forgot, I have 4 frames in Form2 and they are linked with 4 cell values (A2:A4).
What if I want to add several canditions?
 
Upvote 0
Just remember the sequence:
Load the form,
manipulate/populate the controls,
show the form.

If you have several conditions consider a Select Case statement. See the help file.
 
Upvote 0

Forum statistics

Threads
1,216,196
Messages
6,129,462
Members
449,511
Latest member
OttosArmy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top