Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

How to avoid Valid when a record is Canceled
John Koziol, August 1, 1998
A common problem is that Valid always fires, regardless of the actual status of the add or edit. Logically, if an edit is being cancelled, you do not want to enforce validation. There is a way to do it. If involves using some old (but still supported) Fox commands. What this code does is look for t...
Summary
A common problem is that Valid always fires, regardless of the actual status of the add or edit. Logically, if an edit is being cancelled, you do not want to enforce validation. There is a way to do it. If involves using some old (but still supported) Fox commands. What this code does is look for the "cancel" button and test the mouses position and "button down" status to see if the cancel button is being clicked. If it is, Valid returns True and the control can be left without validation. To use this code, substitute your form's name for MyForm and your cancel buttons name for THISFORM.cmdCancel. You could actually block several controls from validation by just reiterating this code for every control that you want to skip validation on.
Description
LOCAL nCancelTop,nCancelHeight,nCancelLeft,nCancelWidth
nCancelTop=THISFORM.cmdCancel.Top
nCancelBottom=nCancelTop+THISFORM.cmdCancel.Height
nCancelLeft=THISFORM.cmdCancel.Left
nCancelRight=nCancelLeft+THISFORM.cmdCancel.Width
IF BETWEEN(MROW("MyForm",3),nCancelTop,nCancelBottom) AND ;
   BETWEEN(MCOL("MyForm",3),nCancelLeft,nCancelRight) AND ;
   MDOWN()
    RETURN .T.
ENDIF
John Koziol, Ultimate Software
John Koziol was an independent consultant and developer off and on for almost 20 years before joining Microsoft in 2001. Since leaving in 2005 he has been involved in several cutting-edge projects using .Net (WPF, C#), SQL Server, and other tools. He is currently a software engineer specializing in model-based testing (MBT) for Ultimate Software in Weston, Florida. He has written numerous articles on VFP related topics for both print and on-line media. He was a Charter Member MCSD and was awarded Microsoft's MVP award from 1998 through 2001. John is married and has three children.
More articles from this author
John Koziol, January 8, 1999
There are usually a lot of posts on the UT regarding numeric bound columns in ComboBoxs, mainly in that people do not get the expected value returned. This is due to the BoundTo property. It defaults to .F. (False) and this means that character listed values will react as you would expect (List ...
John Koziol, January 1, 2001
This is the presentation article for a introduction to data buffering for experienced FPD/FPW people I gave. It's an overview to buffering and basic buffering uses and commands. Data Buffering in Visual FoxPro Introduction to Data Buffering in Visual FoxPro Prepared for the Tal...
John Koziol, October 26, 1999
Spell checking test from VFP, using Microsoft Word's dictionary is so easy it's painful.
John Koziol, December 1, 2006
John Koziol Column
John Koziol, February 10, 2000
Creating a Data Link is a bit different than in Windows NT, 95, and 98 due to the fact that the MDAC (Data Access Components) are built into the operating system. Here it is: Open a folder. Right-click in the folder, select New and then Text File. Go to the Folder menu item in the folder and c...
John Koziol, September 17, 1998
To create a virtual GotFocus and LostFocus for a grid, create a Container class and put a Grid into it. If you change BorderWidth and BackStyle to make the Container transparent, you can then drop it on a Form with only the Grid visible. The Container *has* a Got and LostFocus. And they will fi...
John Koziol, February 1, 2002
FoxPro Report Designer has always been a great tool, very easy and efficient. However, developers must very often design reports in a format that can be easily viewed by third parties, specially the ones that must be visualized from a non-VFP application. The only native format the rep...