Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid and command button to save
Message
 
 
À
21/11/2002 10:16:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00725200
Message ID:
00725215
Vues:
22
This message has been marked as the solution to the initial question of the thread.
>Hi
>
>I have one grid and one command button to save .
>
>when user is in grid , and change one field , for example old value is 5 , new value is 10 ; if user make enter ou tab , and after click in command button to save , everything works good .
>
>But if user don´t make enter or tab , and click in command button to save ,
>VFP save in other tables the old value 5 , and not the new value 10 .
>
>
>Help me , please
>
>Thanks

The problem is, that Valid method of textbox is not fired (and especially if you use some Key, like F2, to save records). Here is a code I use to force values to be written:
* code from  06/06/2002 Vlad Grynchyshyn
	local oObj
	if type('thisform.activecontrol.name')='C'
		oObj = .activecontrol
&& If it's a grid, we need to calculate the active control
		if upper(m.oObj.baseclass) == "GRID"
			nIndex = m.oObj.activecolumn
			for i=1 to m.oObj.columncount
				if m.oObj.columns(i).columnorder = nIndex
					nIndex = i
					exit
				endif
			endfor
			oObj = m.oObj.columns(nIndex)
			oObj = evaluate("m.oObj." + m.oObj.currentcontrol)
		endif

&& Check if control has different value than its ControlSource
		if proper(m.oObj.baseclass)='Textbox' and not empty(m.oObj.controlsource) ;
				and !(m.oObj.value==evaluate(m.oObj.controlsource))
			m.oObj.value = m.oObj.value && Updated:NN: 06/07/02
			lReturn = m.oObj.valid() && This is enough to write changes into ControlSource
			if (vartype(m.lReturn)='N' and m.lReturn = 0) or m.lReturn = .f.
				return .f.
			endif
		endif
	endif
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform