Solved

Lost focus on listbox and picturebox

Posted on 2014-12-01
10
99 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 45

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 45

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
 
LVL 45

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 45

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 45

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now