Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why Trigger failed, more details...
Message
De
27/01/2003 06:54:12
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00743645
Message ID:
00745671
Vues:
28
This message has been marked as a message which has helped to the initial question of the thread.
>If it is not asking too much can you share the UDF with me.

No problem. The field name "Spanish" should be renamed to "Message" in the function.

I kept the original function (with texts in Spanish), and inserted comments for translating the texts.

Table Validation has the following structure:
Table    C(30)
Order    I
Rule     M
Message  M
Comments M
Level    N(1)
And here is the function:
**********************************************************************
FUNCTION RecordValid(tcTableName, llEvaluateAllRules)
	* Record validation.
	* Meant to be invoked from form.valid(<tablename>).
	* Can also be invoked from other places, for instance, triggers.

	tcTableName = lower(tcTableName)

	* save and change settings
	local lnOldAlias, lcOldExact
	lnOldAlias = select()
	lcOldExact = set("exact")
	set exact off

	* open validation table
	if used("validation")
		select validation
	else
		select 0
		use validation again
	endif
	set order to "mainorder"

	* evaluate all errors defined in rules table
	local lcErrorText, llError
	lcErrorText = ""
	tcTableName = padr(tcTableName, len(Table))
	seek tcTableName
	scan while table = tcTableName
		select (lnOldAlias)
		if not evaluate(validation.rule)
			* Adv. means warning.
			lcErrorText = lcErrorText + iif(validation.warning, "Adv.: ", "Err.: ") + validation.spanish
			if not validation.warning
				llError = .T.
			endif
			if llEvaluateAllRules
				lcErrorText = lcErrorText + chr(13)
			else
				exit
			endif
		endif
		select validation
	endscan

	* show error message
	if not empty(lcErrorText)

		* "Can't save", "Warning when saving",
		* "Changes saved", "Error saving", "Warning saving"
		MessageBox(iif(llError, "No se pudo grabar:", "Advertencia al grabar:") + chr(13) + chr(13);
			+ lcErrorText + iif(llError, "", chr(13) + "Se grabaron los cambios."),;
			16, iif(llError, "Error al grabar", "Advertencia al grabar"))
	endif

	* restore environment and return success status
	use in validation
	select (lnOldAlias)
	set exact &lcOldExact
	return not llError
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform