From: McCrayBill@SpringMind.com   
      
   On Wed, 04 Apr 2007 09:15:03 -0400, Kenneth   
    wrote:   
      
   >   
   > Howdy,   
   >   
   > I added a date field (called ViewDate) to a particular table   
   > because I want a form that displays that table to behave in   
   > the following way:   
   >   
   > I wanted ViewDate to display today() whenever a record was   
   > viewed (whether or not it was modified.)   
   >   
   > The form is set up so that the cursor goes to a LastName   
   > field when the form opens, and so, on the arrive of that   
   > field, I just put in a line of code to modify ViewDate.   
   >   
   > I set the arrive of LastName simply as:   
   >   
   > edit()   
   > ViewDate = today()   
   > endEdit()   
   >   
   > but then saw that I was in a continuous loop of locking, and   
   > unlocking the record.   
   >   
   > What is the proper way to approach this?   
      
   I had a similar problem recently. Here's the way I solved it.   
      
   * Declare a logical variable (I called it Flag) for the form.   
   * In the open method for the form, set Flag to False.   
   * Make your code   
      
   If not Flag Then   
    Flag = True   
    edit()   
    Viewdate = today()   
    endEdit()   
    Flag = False   
   EndIf   
      
   When you first enter this code, Flag is false, so you enter the Then   
   Clause. Flag is set. If this event is retriggered by code in the   
   Then Clause, Flag is now True, so the Then Clause does not execute.   
      
   Bill   
      
      
      
      
      
      
   ----------------------------------------------------------------   
   Reverse halves of the user name for my e-address   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|