Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Verification....
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00459464
Message ID:
00460380
Vues:
23
>Just to add a little to Trey's excellent advice: You'll need to either use table buffering on the tables in the grids or use views. Otherwise the data will be saved automatically when the pointer moves to another record.
>
>When there are specific fields that MUST have data I've found it is often easier to use a combination of read-only grid and read/write fields. The user scans through the grid and the data for the active row is shown in the fields for editing. For a new record, these fields can be blank or filled with default values. This way you can be certain that all required fields are entered before the user can move to another row in the grid or another page in the form.
>

Actually, it sounds like an ideal situation for using GETFLDSTATE() and EMPTY(); GETFLDSTATE() can tell you exactly which fields have been edited during buffered editing. You can determine which records have been edited, appended or deleted, and which fields have been altered. In conjunction with EMPTY(), a determination can be made as to whether or not the record has been changed during this operation, and for any field not changed, you can then check if the field is empty using code something like:
SELECT cMyRandomCursor
LOCAL cFieldState, nOccurs, nPosn, cBadRecs, cFields
#DEFINE NOEDITNODELETE  "1"
#DEFINE EDITORDELETED   "2"
#DEFINE ADDNOCHANGEMADE "3"
#DEFINE ADDANDEDITED    "4"
cBadRecs = ''
* 
SCAN
   cFieldState = SUBST(GETFLDSTATE(-1),2)  && state for all fields
   *  SUBST() drops the status of the deletion flag
   DO CASE
   CASE ADDNOCHANGEMADE $ cFieldState 
      * appended record with at least one unchanged field
      cBadRecs = cBadRecs + ',' + TRANSFORM(RECNO())
   CASE EDITORDELETED $ cFieldState
      cFieldsEmpty = ''
      nOccurs = 1
      nPosn = AT(NOEDITNODELETE,cFieldState,nOccurs)
      DO WHILE nPosn > 0
         IF  EMPTY(EVAL(FIELD(nPosn)))
            cFieldsEmpty = cFieldsEmpty + ' ' + FIELD(nPosn)
         ENDIF
         nOccurs = nOccurs + 1
         nPosn = AT(NOEDITNODELETE,cFieldState,nOccurs)
      ENDDO
      IF LEN(cFieldsEmpty) > 0
         *  One or more empty fields
         cBadRecs = cBadRecs + ',' + TRANSFORM(RECNO()) + ;
                    '{' + SUBST(cFieldsEmpty,2) + '}'
      ENDIF
   ENDCASE
ENDSCAN
IF LEN(cBadRecs) = 0
   *  Cursor is OK, no empty fields
ELSE
   cBadRecs = SUBST(cBadRecs,2)  && strip leading ','
   *  cBadRecs is a space delimited list of records with empty values
   *  Negative record numbers are records appended since last TABLEUPDATE(),
   *  any positive record number lists the empty fields of that record in {}
ENDIF
? cBadRecs
>HTH
>Barbara
>
>>Thank you for your assistance Trey! I do; however, have to use grids because the end user needs to be able to enter multiple instances of items. for instance: one company with the listing of 3 vice presidents. If you have any easier suggestions, it would be much appreciated!
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform