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

  1. *****************************************************************
  2. * FILE: refresh.prg
  3. * Shows how to use OnGotFocus to refresh the data-linked fields
  4. * in a form with the current data in a database. Accompanies
  5. * Chapter 22 in the "Programmer's Guide."
  6. *****************************************************************
  7.  
  8. *---------------------------------------------
  9. * Define a form that shows three fields of 
  10. * the Goods database (GOODS.DBF in SAMPLES).
  11. * The OnGotFocus procedure RGRefresh refreshes
  12. * the form every time the user gives it focus.
  13. *---------------------------------------------
  14. DEFINE FORM ReadGoods FROM 10,12 TO 18,60 ;
  15.    PROPERTY ;
  16.       Text "Number of parts on hand", ;
  17.       OnGotFocus RGRefresh, ;
  18.       OnOpen RGOpen, ;
  19.       OnClose RGClose
  20.  
  21. DEFINE TEXT t1 OF ReadGoods AT 1,1 ;
  22.    PROPERTY Text "Part Name:", Label .F.
  23. DEFINE ENTRYFIELD PartName OF ReadGoods AT 1,14 ;
  24.    PROPERTY DataLink "Part_Name", Width 32
  25.  
  26. DEFINE TEXT t2 OF ReadGoods AT 3,1 ;
  27.    PROPERTY Text "Description:", Label .F.
  28. DEFINE ENTRYFIELD Descr OF ReadGoods AT 3,14 ;
  29.    PROPERTY DataLink "Descript", Width 32
  30.  
  31. DEFINE TEXT t3 OF ReadGoods AT 5,1 ;
  32.    PROPERTY Text "On hand:", Label .F.
  33. DEFINE ENTRYFIELD OnHand OF ReadGoods AT 5,14 ;
  34.    PROPERTY DataLink "Qty_Onhand", Width 6
  35.  
  36. * Code that defines rest of form--allows user to select a part
  37.  
  38. lvoid = ReadGoods.Open()        && Open the form window.
  39.  
  40. PROCEDURE RGOpen                && OnOpen event handler for ReadGoods.
  41.    USE Goods IN 1 NOUPDATE ORDER Part_id
  42. RETURN
  43.  
  44. PROCEDURE RGRefresh             && OnGotFocus event handler for ReadGoods.
  45.    lVoid = this.Refresh()       && Refresh form so data is current.
  46. RETURN
  47.  
  48. PROCEDURE RGClose               && OnClose event handler for ReadGoods.
  49.    USE IN 1                     && Close Goods database.
  50.    lVoid = ReadGoods.Release()  && Release form window and its now
  51.    RELEASE ReadGoods            && null object reference variable. 
  52. RETURN
  53. * EOP REFRESH.PRG
  54.