>JOsé,
>
>You already suggested me xcase, but as I already invested in stonefield database kit, and as xcase isn't for free, I'm still hesitating.
>
>For now I'm still struggling with some problems that have to be sorted out before I can take full advantage of views. Untill now I have tried some advanced options on views using eview from erik moore and eview does what I want, but still my basic problems remain. (BTW : erik did a modification on my demand to eview in no time = thanks eric !!)
>
>My BIG problem is, and it seems that I alone have the problem, is that my grids based on updateable views start acting very weird if the update to the basetables are rejected due to basetablerules. As long as this problem isn't solved, and I'm afraid there is no solution, I'm doing checkings on the data in the view instead letting the databaserules do their work.
>What I find VERY strange is that I'm doing nothing very special and that no-one seems to have encountered this problem.
Pascal,
I do all my checking before attemptin to save, so I am pretty sure the data will get saved properly.
I completely dropped the use of field rules because they would bite in table buffered views. Instead of that, I place all my validation logic into a beforeSave() routine pertaining to the business object. If the beforeSave() routine returns .F., then there is no save.
For a table buffered view, I arrange things like this:
LOCAL loSelect, ;
lnRetVal, ;
lnNext, ;
lcField
loSelect = CREATEOBJECT("cSelect", this.cAlias)
lnNext = GETNEXTMODIFIED(0)
DO WHILE lnNext # 0
GO (lnNext)
lcField = this.cAlias + ".cYear"
IF EMPTY( EVAL( lcField))
REPLACE &lcField WITH goApp.cYear
ENDIF
IF goApp.lUseMerciAuto AND yVersement >= goApp.yMerciAuto
lcField = this.cAlias + ".lMerci"
REPLACE &lcField WITH .T.
ENDIF
DO CASE
CASE EMPTY( dVersement)
lcField = this.cAlias + ".dVersement"
thisform.FindControl( lcField, "Veuillez compléter la date du versement.")
CASE yVersement = NTOM( 0)
lcField = this.cAlias + ".yVersement"
thisform.FindControl( lcField, "Veuillez compléter le montant versé.")
CASE EMPTY (cBanqueId)
lcField = this.cAlias + ".cBanqueId"
thisform.FindControl( lcField, "Veuillez compléter la banque.")
OTHERWISE
lnRetVal = .T.
ENDCASE
IF ! lnRetVal
EXIT
ENDIF
lnNext = GETNEXTMODIFIED(lnNext)
ENDDO
RETURN lnRetVal
The findcontrol utility is a little goodie that will make the control flame red to capt the user attention. In case of a grid, it will make the column red.
José