Lost focus on listbox and picturebox

I have a print button that opens a picturebox containing the printers on a users machine
If they do not choose a printer I am trying to make the picturebox disappear both these do not work:

Private Sub picPrinters_LostFocus()
Me.picPrinters.Visible = False
End Sub


Private Sub lstPrinters_LostFocus()
picPrinters.Visible = False
End Sub

Open in new window

printer
How to do this ?
isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Can you supply a small demo workbook?
0
isnoend2001Author Commented:
Thanks marty, but it's not a workbook i think workbook is excel it's part of a huge project.
I could make a small project
0
Martin LissOlder than dirtCommented:
Sorry, I work with a lot of people and forget who is Excel and who is VB6. A small project would be great.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
This will do it
Private Sub lstPrinters_Click()
picPrinters.Visible = False
End Sub
0
isnoend2001Author Commented:
Yes, already have that code in the actual print when a selection is made, but just trying to make it disappear in case they don't make a selection
0
Martin LissOlder than dirtCommented:
Well then if you are sure that the listbox has focus (you can use SetFocus to make sure it does), this will work.

Private Sub lstPrinters_LostFocus()
picPrinters.Visible = False
End Sub
0
isnoend2001Author Commented:
Sample Project attached
Select-Printer.zip
0
isnoend2001Author Commented:
The listbox may or may not get the focus. just want the pic to disappear if somewhere else is clicked
0
Martin LissOlder than dirtCommented:
This sets the form's KeyPreview property to True and then closes the picturebox form's click event.
Q-28572544.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Thanks Marty
Better yet i can use the forms mouse-move.The picprint is directly below the print button(no space)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.