Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate input into grid
Message
From
26/05/2005 01:08:23
Walter Meester
HoogkarspelNetherlands
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01017586
Message ID:
01017712
Views:
25
Hi chuck,

This is a difficult one......
I've spend many hours in figuring this out myself (because of lack of examples out here).

As Cetin netioned the first step is using GETNEXTMODIFIED(). But this does not cover it all. When the cursor is in a field and you have changed some text but did not enter it yet, the underlying table will get update just after the tableupdate() potentially creating really nice looking error messages.

The best strategy is to find such circumstances... The following is for finding changes in a record buffered grid, but it also applies to table buffered grids, if you mix in a GETNEXTMODIFIED() function.
LOCAL lRet, oColumn, cControlsource, nCol, oActiveControl, cView, cAliases, cAlias, nT

IF THISFORM.Visible AND USED(THIS.RecordSource)
	** Checking if the DefaultAlias has been changed

	lRet = NVL(!EMPTY(THIS.RecordSource) AND !EOF(THIS.RecordSource) AND ;
			GETFLDSTATE(-1,THIS.RecordSource) != REPLICATE("1",FCOUNT(THIS.RecordSource)+1), .F.)
	
	** Checking the currently active control
	
	oActiveControl = .NULL.
	DO CASE
		CASE TYPE("THISFORM.ActiveControl.ControlSource")="C"
			** The control has an controlSource
			oActiveControl = THISFORM.ActiveControl
			
		CASE TYPE("THISFORM.ActiveControl.Recordsource") = "C"
			** The current control is a grid. So get the current control in the grid		
			nCol = THISFORM.ActiveControl.ActiveColumn
			FOR EACH oColumn IN THISFORM.ActiveControl.Columns
				IF oColumn.ColumnOrder = nCol AND TYPE("oColumn."+oColumn.currentcontrol+".Name")="C" 
					oActiveControl = EVAL("oColumn."+oColumn.currentcontrol)
					EXIT
				ENDIF
			ENDFOR
	ENDCASE

	IF !ISNULL(oActiveControl) AND TYPE("oActiveControl.ControlSource")="C" AND !EMPTY(oActiveControl.ControlSource)
		** So there is an active control, either in a grid or on the form or in some other container.
		
		cControlSource = oActiveControl.ControlSource
		cAlias = UPPER(JUSTSTEM(cControlSource))
		
		** Check if the controlsource is refering to a table which is to be checked.
		
		IF cAlias == UPPER(THIS.RecordSource) 
			
			lRet = lRet OR (TYPE(cControlsource) == TYPE("oActiveControl.Value") AND ;
				EVAL(cControlSource) <> oActiveControl.Value)
		ENDIF
	ENDIF
ENDIF
RETURN NVL(lRet, .F.)
>What is the best way to verify that a user entered something into a 2 column grid before doing tableupdate.
>
>Thanks, Chuck
Previous
Reply
Map
View

Click here to load this message in the networking platform