home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / DATABASE / DBASE5 / CUA_SAMP.ZIP / LOOKREF.PRG < prev    next >
Encoding:
Text File  |  1994-06-24  |  2.5 KB  |  84 lines

  1. PROCEDURE LookRef
  2. PARAMETERS pcAlias, poLookup
  3. *----------------------------------------------------------------------------
  4. * NAME
  5. *   LookRef - Refresh fields in the lookup table after a record movement
  6. *
  7. * PARAMETERS
  8. *   pcAlias     = Alias name to look for using DataLink
  9. *   poLookFld   = oRef to lookup field
  10. *
  11. *----------------------------------------------------------------------------
  12.     PRIVATE oParent, oFirst, oCurrent, cDataLink, cData
  13.     *------------------------------------------
  14.     *-- For each modified field with a datalink
  15.     *------------------------------------------
  16.     oParent = poLookup.Parent
  17.     oFirst = oParent.First
  18.     oCurrent = oFirst
  19.     DO WHILE .T.
  20.  
  21.         IF TYPE( "oCurrent.DataLink" ) = "C"
  22.  
  23.             *------------------------------------------
  24.             *-- Check to see if the fields was modified
  25.             *------------------------------------------
  26.             IF oCurrent.Modified()
  27.  
  28.                 *--------------------------------------------
  29.                 *-- Save the modified value to a holding area
  30.                 *--------------------------------------------
  31.                 oCurrent.HoldValue = oCurrent.Value
  32.  
  33.             ENDIF
  34.  
  35.         ENDIF
  36.  
  37.         oCurrent = oCurrent.After
  38.  
  39.         IF oCurrent = oFirst
  40.             EXIT
  41.         ENDIF
  42.     ENDDO
  43.  
  44.     *--------------------------------------------------------------------
  45.     *-- How issue a Refresh().  This moves the values from the new record
  46.     *-- into the entryfields, but it also resets the values in the master
  47.     *-- file.  That's why we stashed them above.
  48.     *--------------------------------------------------------------------
  49.     SELECT( oParent.CurrMast )
  50.  
  51.     lVoid = oParent.Refresh()
  52.  
  53.     SELECT( pcAlias )
  54.  
  55.     *-------------------------------------------------------------
  56.     *-- For each of the fields with stashed values, move them back
  57.     *-------------------------------------------------------------
  58.     oCurrent = oFirst
  59.     DO WHILE .T.
  60.  
  61.         IF TYPE( "oCurrent.HoldValue" ) # "U"
  62.  
  63.             *--------------------------------------------------------
  64.             *-- Copy the HoldValue to Value and release the HoldValue
  65.             *--------------------------------------------------------
  66.             oCurrent.Value = oCurrent.HoldValue
  67.             RELEASE oCurrent.HoldValue
  68.  
  69.         ENDIF
  70.  
  71.         oCurrent = oCurrent.After
  72.         IF oCurrent = oFirst
  73.             EXIT
  74.         ENDIF
  75.     ENDDO
  76.  
  77.  
  78. RETURN
  79. *-- EOP: LookRef WITH pcAlias, poLookup
  80.  
  81.  
  82.  
  83.  
  84.