| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > FileManager > FileManager Methods >====== TryFetch (try to get a specific record by key value) {{c6h0009.jpg|C6H0009.jpg}} ====== | [[throwmessage pass an error and text to the error handler .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[tryinsert try to add a new record .htm|{{btn_next_n.gif|Next page}}]] | | || **TryFetch( **//key //**), VIRTUAL, PROC** {{blk2blue.jpg|blk2blue.jpg}} | **TryFetch** | Gets a specific record by its key value. | | //key// | The label of the primed KEY. | The **TryFetch **method gets a specific record by its key value. You must prime the key before calling TryFetch. If the key is not unique, TryFetch gets the first record with the specified key value. The Fetch method provides a slightly different (automatic) alternative for fetching specific records. **Implementation:** TryFetch tries to get the specified record. If it succeeds, it returns Level:Benign. If it fails, it returns Level:Notify and does not clear the record buffer. See //Error Class //for more information on Level:Benign and Level:Notify. **Return Data Type:**     BYTE **Example:** ** PROGRAM** ** INCLUDE('ABFILE.INC')             !declare FileManager class** ** MAP                               !program map** ** END** **GlobalErrors  ErrorClass           !declare GlobalErrors object** **Access:State  CLASS(FileManager)   !declare Access:States object** **              END** **States       FILE,DRIVER('TOPSPEED'),PRE(ST),CREATE,BINDABLE,THREAD** **StateCodeKey KEY(ST:StateCode),NOCASE,OPT,PRIMARY** **Record        RECORD,PRE()** **StateCode      STRING(2)** **State          STRING(20)** **              END** **             END** **  CODE** ** !program code** ** !get the state record for Florida** ** ST:StateCode = 'FL'              !prime the state key for the fetch** ** IF Access:States.TryFetch(ST:StateCodeKey)!fetch the record** **  GlobalErrors.Throw(Msg:FieldNotInFile)  !handle any errors yourself** ** END** **See Also:**     [[fetch get a specific record by key value .htm|Fetch]] , [[get read a record or entry .htm|GET]]