lost focus problem

Posted on 1999-06-30
Medium Priority
Last Modified: 2010-05-02
is there a way to know what caused the lost focus of a field ( for example : move to another field, press on a bottun, go to an event ... etc )
i need it in order to check the field validation for each case exept when the user press the exit application button/event
Question by:yaelt
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
  • 2
  • 2
  • 2

Expert Comment

ID: 1521020
Move the code from the click event on the Exit button to the MouseDown event on the Exit button.

Expert Comment

ID: 1521021
I have a perfect solution for it.
In the LostFocus event of that control you should add some code like this
   If Form1.ActiveControl.Name = "cmdExit"
       Exit sub
   End If
   ********* Code for validation *************
Name propery will not be there at design time. So don't worry if after pressing . you see no popup.
I assumed that cmdExit is Name of your Exit button, and Form1 is your current form name.


Author Comment

ID: 1521022
thanks ! but i still have trouble when i m activating the exit button with a short cut key ( like alt+e 4 example )
how can i prevent the validation check then ?
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 1521023
Have you tried apratima answer?

This should solve it.

Author Comment

ID: 1521024
this comment is 4 apratima :
your answer is correct! but inorder to give u the points,please comment this qst again ( cause now i can accept only the last anser )


Accepted Solution

apratima earned 40 total points
ID: 1521025
Thanks for the points

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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

719 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