Solved

Lost focus on listbox and picturebox

Posted on 2014-12-01
10
101 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

914 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

19 Experts available now in Live!

Get 1:1 Help Now