Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP version that saves the value of control with focus
Message
De
10/06/2003 14:09:27
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00798195
Message ID:
00798519
Vues:
30
Hello Brenda.

The code that you gave for the grid, where is that inserted? In the grid1.valid or the SAVE method (all my SAVE logic is in custom methos of a container)?

Assuming that you base data aware form class has a method called Save() that is called from the click of the toolbar Save button, add a method called WriteBuffer() to your base data awazre form class. Code like this in the WriteBuffer() method:
LOCAL loColumn, loActiveControl, loControl, llRetVal

llRetVal = .T.
IF TYPE( 'Thisform.ActiveControl.Name' ) = 'C'
  loActiveControl = Thisform.ActiveControl
  IF UPPER( loActiveControl.BaseClass ) # 'GRID'
    *** If there is code in the valid method of the active control
    *** And the entry is invalid, the error message will display
    *** But the rest of the code code will continue to run and save
    *** the bad data anyway. So we cannot just issue a SetFocus()
    IF NOT EMPTY( loActiveControl.Valid() )
      *** We still have to cause the Valid to fire to update the data
      *** from what is in the buffer because the previous line
      *** does not cause the Valid to fire, it merely runs any code
      *** in that method
      loActiveControl.SetFocus()
      llRetVal = .T.
    ELSE
      llretVal = .F.
    ENDIF
  ELSE
    FOR EACH loColumn IN loActiveControl.Columns
      IF loActiveControl.ActiveColumn = loColumn.ColumnOrder
        loControl = EVAL( 'loColumn.'+ loColumn.CurrentControl )
        IF NOT EMPTY( loControl.Valid() )
          loControl.SetFocus()
          llRetVal = .T.
        ELSE
          llRetVal = .F.
        ENDIF
        EXIT
      ENDIF
    ENDFOR
  ENDIF      
ENDIF

RETURN llRetVal
Now your save method looks like this:
IF Thisform.WriteBuffer()
  IF TABLEUPDATE( 0, .F., Thisform.cPrimaryTable )
    *** Peachy keen all is well
  ELSE
    MESSAGEBOX( 'Unable to save data right now...', 16, 'Major WAAAHHHH!' )
  ENDIF
ENDIF
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform