Solved

Capture text box LostFocus

Posted on 1997-03-13
1
271 Views
Last Modified: 2012-08-13
I use Crescent text box controls in 16-bit VB 4.0.  I have some code behind the text boxes' LostFocus event that need to be executed (mostly data validation).  However, when I click on one of the menu itmes in MDIOnline form, the LostFocus event of currently selected text box did not get triggered.  I tried to use SendKeys "{Tab}" in menu item click event, but the LostFocus event still did not get fired.  Can somebody provide me with a pointer?  Thanks in advance.
0
Comment
Question by:Copland
1 Comment
 
LVL 5

Accepted Solution

by:
volking earned 100 total points
ID: 1424475
First, you're never going to get the lost focus event to fire. I encounter the same problem about 10 months ago and spent almost 2 days chasing it.

My best advice is

1) move ALL validation code from ALL controls to a central SUB.

2) in each control's GotFocus event, set a global variable (of type control) to whatever control just got the focus.

3) In each control's Lost focus event, call the central sub.

Now here's the tricky part ... Since you're using Crescent's QuickPac controls (by the way I LOVE THOSE CONTROLS!) anyways, QuickPak has a control called CSForm. When you add CSForm to a form, you get a bunch of new events. The two events you're interested in are MenuBrowse and SysMenuClick.

In those two events, you also fire the Centralized SUB.

You may also want to take a look at the CtlNotify event. I played with it a bit, but to be honest, the danged thing fired too much, especially in an MDI environment.

Good luck.
============> Frederick


0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

831 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