Solved

Lost focus on listbox and picturebox

Posted on 2014-12-01
10
106 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 47

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 47

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
Industry Leaders: 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 47

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 47

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 47

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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 58
Windows Script Host failed (Access is denied.) error 6 341
vb6 connector to mongodb 2 144
Macro problems with Excel file 6 28
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

697 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