Hi everyone,
I hope you can help me since I'm really struggling to show and hide pictures in my userform, depending on the value in a combobox.
My combobox is called comboItem and I want to show the picture imgOwls as default, UNLESS the value in combobox comboItem is "Blocks". If the value in comboItem is "Blocks", then I want to show a picture of wooden blocks which I have named imgBlocks. The idea is to preview the item in the userform before adding it to my database. The picture of the Owls is my default picture which should be shown when no value is selected in the combobox.
I have tried the following VBA code;
If comboItem.Value = "Blocks" Then Me.imgBlocks.Visible = True
If comboItem.Value = "Blocks" Then Me.imgOwls.Visible = False<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
If comboItem.Value <> "Blocks" Then Me.imgBlocks.Visible = False<o></o>
If comboItem.Value <> "Blocks" Then Me.imgOwls.Visible = True<o></o>
The code above works to some degree; I just can't get rid of the imgBlocks picture and get back to the default picture (imgOwls).
I have also tried this code:
If comboItem.Value = "Blocks" Then
Me.imgOwls.Visible = False
Me.imgBlocks.Visible = True
Else
Me.imgOwls.Visible = True
End If
I have chosen Visible = True for imgOwls in the properties menu, while I have chosen Visible = False for imgBlocks.
I would really appreciate your input to resolve this frustrating problem.
Thanks in advance!
Best regards
Ulrika
I hope you can help me since I'm really struggling to show and hide pictures in my userform, depending on the value in a combobox.
My combobox is called comboItem and I want to show the picture imgOwls as default, UNLESS the value in combobox comboItem is "Blocks". If the value in comboItem is "Blocks", then I want to show a picture of wooden blocks which I have named imgBlocks. The idea is to preview the item in the userform before adding it to my database. The picture of the Owls is my default picture which should be shown when no value is selected in the combobox.
I have tried the following VBA code;
If comboItem.Value = "Blocks" Then Me.imgBlocks.Visible = True
If comboItem.Value = "Blocks" Then Me.imgOwls.Visible = False<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
If comboItem.Value <> "Blocks" Then Me.imgBlocks.Visible = False<o></o>
If comboItem.Value <> "Blocks" Then Me.imgOwls.Visible = True<o></o>
The code above works to some degree; I just can't get rid of the imgBlocks picture and get back to the default picture (imgOwls).
I have also tried this code:
If comboItem.Value = "Blocks" Then
Me.imgOwls.Visible = False
Me.imgBlocks.Visible = True
Else
Me.imgOwls.Visible = True
End If
I have chosen Visible = True for imgOwls in the properties menu, while I have chosen Visible = False for imgBlocks.
I would really appreciate your input to resolve this frustrating problem.
Thanks in advance!
Best regards
Ulrika