""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   BROWSE OR EDIT OLD ROWS WHILE ENTERING NEW ROWS IN A FORM
   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   PRODUCT   :  R:BASE                  VERSION      :  3.1
   CATEGORY  :  FORMS                   SUBCATEGORY  :  EDIT & ENTER
   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
   You can enter and edit in the same form by using the BROWSE command in
   an entry/exit procedure (EEP). Use this technique to display related
   rows that come from the same table, a different table, a view, or
   several tables. Although you can't use a form in an EEP, the BROWSE
   command makes it easy to view historical information on a client,
   patient, or customer while entering data using a form.
 
   When browsing a single table, a user can press [F4] to edit existing
   values. If you don't want the user to be able to edit existing values,
   use BROWSE DISTINCT instead of BROWSE.
 
 
   SEEORDER.EEP Example
   """"""""""""""""""""
   SEEORDER.EEP (shown below) is an example you can use with the ORDERS
   form in the HIFI database that comes with R:BASE. The ORDERS form in
   HIFI is used with ENTER to add new orders to the ORDERS table.
   SEEORDER.EEP uses BROWSE to display previous orders as you enter a new
   order, and it looks up the last name in SALESPEOPLE.
 
 
   Step by Step Solution
   """""""""""""""""""""
   STEP 1 *** Back up the HIFI database and open it. Then choose
   Create/modify under Forms on the R:BASE Main Menu, and then choose the
   ORDERS form under Modify. Next, choose Define under Variables to enter
   this expression:
 
     vstoreid = storeid
 
   VSTOREID holds the store identification number for the current row.
 
   STEP 2 *** Under Layout, choose "Field settings" and then "Storename."
   On the second page, enter Yes to display field help, and enter this
   help line: "Press F2 to view previous orders." Then enter SEEORDER.EEP
   as the exit procedure.
 
   STEP 3 *** Create the EEP.
 
     *( SEEORDER.EEP--Show previous orders.)
     SET VAR vlastkey = (LASTKEY(0))
     IF vlastkey <> '[F2]' OR vstoreid IS NULL THEN
       RETURN
     ENDIF
     SET VAR vwhere = ('storeid=' + (CTXT(.vstoreid)))
     SET COLOR white ON blue
     NEW
     BROWSE t1.ordernumber=6, t2.lastname, t1.ponumber=7, +
       t1.orderdate=8, t1.units=4, t1.price=9, +
       t1.totalsale=9, t1.discount=6 +
       FROM orders t1, salespeople t2 +
       WHERE (t1.employeeid=t2.employeeid) AND &vwhere
     CLEAR VAR vwhere, vlastkey
     RETURN
 
   Customize this EEP for your application. For example, if your common
   column (STOREID in the example) is TEXT, you need to surround its
   value (.VSTOREID) with single quotation marks (CHAR(39)) on the "SET
   VAR vwhere" line, similar to this example:
 
     SET VAR vwhere=('storeid=' + CHAR(39) + CTXT(.vstoreid) + CHAR(39))
 
   The BROWSE command in SEEORDER.EEP uses two tables (ORDERS and
   SALESPEOPLE), so the user can browse historical data but can't change
   it. If you want the user to be able to press [F4] to edit old rows
   while browsing them, eliminate the second table. For example, you
   might use this EEP instead of SEEORDER.EEP:
 
     *( EDORDER.EEP--Edit previous orders.)
     SET VAR vlastkey = (LASTKEY(0))
     IF vlastkey <> '[F2]' OR vstoreid IS NULL THEN
       RETURN
     ENDIF
     SET VAR vwhere=('storeid='+(CTXT(.vstoreid)))
     SET COLOR white ON blue
     NEW
     BROWSE ordernumber=6, ponumber=7, orderdate=8, units=4, +
       price=9, totalsale=9, discount=6 FROM orders WHERE &vwhere
     CLEAR VAR vwhere, vlastkey
     RETURN
 
   T1 and T2 aren't needed when you're using only one table.
 
   These EEPs are smart. They use the LASTKEY function to control whether
   or not the EEP executes. If the user doesn't press [F2], the EEP won't
   execute when the user leaves the field.
 
   STEP 4 *** Test the EEP and modified ORDERS form by entering this
   command:
 
     ENTER orders
 
   Once you're in the form, enter 202 as the store number. Then move to
   the STORENAME field and press [F2]. The form will clear and you'll be
   viewing all the previous orders for that store. When you finish
   viewing the old orders, choose Exit, and R:BASE will return you to the
   form to enter new orders.