Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating data in grid entry
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00678737
Message ID:
00678752
Views:
19
This message has been marked as a message which has helped to the initial question of the thread.
>I want to only allow the user to leave a grid line in a form, if what they entered is valid. I have the code for validity checking, but don't understand how to code the valid method so it won't allow them to leave the grid line.

Marcia Akins has this code in her book. She also posted it few times here. Here is from her earliest posts on this topic:
********************************************************************
*  Description.......: AfterRowColChange
*  Calling Samples...:
*  Parameter List....:
*  Created by........: Marcia Akins
*  Modified by.......:
********************************************************************
lparameters ncolindex
local lnRec2GoTo
with this
*** If there is no record to validate, exit stage left
	if .nRec2Validate = 0
		return
	endif

*** Save the current record number in case we have changed rows
	lnRec2GoTo = recno( .recordsource )
*** Check to see if the row has changed
	if .nRec2Validate # m.lnRec2GoTo
*** We are validating the row we are attempting to leave...set the flag
		.lValidatingRow = .t.
*** Return to the record we just left
		goto .nRec2Validate in ( .recordsource )
*** If it checks out, let the user move to the new row
		if .ValidateCurrentRow()
			goto lnRec2GoTo in ( .recordsource )
		endif
*** Finished with validation...reset flag
		.lValidatingRow = .f.
	endif
endwith
dodefault(m.ncolindex)
*!*	********************************************************************
*!*	*  Description.......: BeforeRowColChange
*!*	*  Calling Samples...: 
*!*	*  Parameter List....: 
*!*	*  Created by........: Marcia Akins 
*!*	*  Modified by.......: 
*!*	********************************************************************
lparameters ncolindex
	with this
		if .lValidatingRow
			nodefault
		else
			.nRec2Validate = recno(.recordsource)
			dodefault(m.ncolindex)
		endif
	endwith
You would need two new properties nRec2Validate and lValidatingRow.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform