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
Solved

Lost focus on listbox and picturebox

Posted on 2014-12-01
10
104 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
  • 5
  • 5
10 Comments
 
LVL 46

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 46

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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 46

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 46

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 46

Accepted Solution

by:
Martin Liss earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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