Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Message from field rule
Message
 
To
20/05/2001 12:13:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00509205
Message ID:
00509336
Views:
18
This message has been marked as the solution to the initial question of the thread.
>Hello.
>
>I wonder, is there a way to use the message on the field validation rule, but not in the default window used to display it?
>
>I write apps in Romanian, and the command buttons have captions in English.
>
>Try to imagine a 50 years old lady looking at the "Revert" word. She won't get the sense there and will call me at 8:00 AM in the next morning, complaining the app doesn't work anymore. "Come here right now and fix it!!" :)
>
>Thank you.

Grigore,
I've dropped the field rules for a long time now. First they are problematic in case you use table buffering. Then you have the translation problem.

I now put them in a BeforeSave() of my bizness objects.

First, in the init() of the bizobj:
WITH THIS
  DIMENSION .aFieldRule[ 2,2]
  .aFieldRule[ 1,1] = ALLTRIM( .cAlias) + '.cProcedureId'
  .aFieldRule[ 2,1] = ALLTRIM( .cAlias) + '.cModeleID'

  .aFieldRule[ 1,2] = 'indiquer la <Procédure>'
  .aFieldRule[ 2,2] = 'indiquer le <Modèle>'
ENDWITH
Then comes the BeforeSave() method (table buffering in this case):
LOCAL lnCount, ;
  loSelect, ;
  lcCode, ;
  lcfield, ;
  lcMessage, ;
  lnNext, ;
  lnRetVal

lnRetVal = .T.

loSelect = CREATEOBJECT("cSelect", ALIAS( SELECT(0)))

this.cGrid1.SetFocus()

SELECT (THIS.cAlias)

lnNext = GETNEXTMODIFIED(0)

DO WHILE  lnNext # 0
  GO (lnNext)
  lnRetVal = .F.
  WITH THIS
   FOR lnCount = 1 TO ALEN( .aFieldRule, 1)
      lcfield   = .aFieldRule[ lnCount, 1]
      lcMessage = .aFieldRule[ lnCount, 2]

      IF EMPTY( EVAL( lcfield)) AND ! DELETED()
        THISFORM.FindControl( lcfield, [Avant de sauvegarder, veuiller ] + lcMessage + [ s'il vous plaît.])
        lnRetVal = .F.
      ELSE
        lnRetVal = .T.
      ENDIF
      IF ! lnRetVal
        EXIT
      ENDIF
     ENDFOR
  ENDWITH
  
  lnNext = GETNEXTMODIFIED(lnNext)
  
  IF ! lnRetVal
    EXIT
  ENDIF
ENDDO

RETURN lnRetVal
The FindControl() method finds the offending control and shows it in red color.

José
Previous
Reply
Map
View

Click here to load this message in the networking platform