* Sample table is home()+"samples\data\customer" * In form Dataenvironment buffering is set to pessimistic * In fact we use rlock() so it could be any type - explicit lock * Form is done with form wizard * A timer (thisform.timer1) is added to form * Wizard buttons (thisform.buttonset1) code is changed as below * To test run same form in two different VFP tasks * txtbtns.init (thisform.buttonset1) thisform.comment = thisform.caption DoDefault() * txtbtns.navrefresh (thisform.buttonset1) DoDefault() thisform.Timer1.reset thisform.Timer1.timer() * txtbtns.cmdEdit.click (thisform.buttonset1) IF !this.parent.editmode RLOCK("Customer") ELSE UNLOCK in "Customer" ENDIF DoDefault() * Thisform.timer1.timer (interval ie:2000) SET reprocess to 1 IF !ThisForm.BUTTONSET1.editmode lCanLock = rlock() UNLOCK ELSE lCanLock = .t. ENDIF IF lCanLock thisform.caption = thisform.comment + space(20)+"..Record available.."+time() ELSE thisform.caption = thisform.comment + space(20)+"..Someone is editing.."+time() ENDIFCetin
* button activating edit >>set reprocess to 1 && Try a lock just once >>if rlock() && Is already locked ? someone editing ? >>* If you could access here then record is free for you >>* and you placed the lock now >>else >> wait window "Sorry someone is editing...Try later." >>endif >> >>* Save or revert button >>* Cleanup code >>unlock && Remove the lock so others can editThis is explicit locking. With explicit locking you should control the unlocking too.