?
Solved

Lost focus on listbox and picturebox

Posted on 2014-12-01
10
Medium Priority
?
109 Views
Last Modified: 2014-12-01
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 ?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40474945
Can you supply a small demo workbook?
0
 

Author Comment

by:isnoend2001
ID: 40474958
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
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40474968
Sorry, I work with a lot of people and forget who is Excel and who is VB6. A small project would be great.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:Martin Liss
ID: 40474988
This will do it
Private Sub lstPrinters_Click()
picPrinters.Visible = False
End Sub
0
 

Author Comment

by:isnoend2001
ID: 40474996
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
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40475002
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
 

Author Comment

by:isnoend2001
ID: 40475008
Sample Project attached
Select-Printer.zip
0
 

Author Comment

by:isnoend2001
ID: 40475014
The listbox may or may not get the focus. just want the pic to disappear if somewhere else is clicked
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40475041
This sets the form's KeyPreview property to True and then closes the picturebox form's click event.
Q-28572544.zip
0
 

Author Closing Comment

by:isnoend2001
ID: 40475059
Thanks Marty
Better yet i can use the forms mouse-move.The picprint is directly below the print button(no space)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question