Listed is the code below that I am wanting to insert new record or update existing record within a view. The intent is to have the system to loop the tableupdate command if, for some reason it returns a FALSE. Am I heading down the right track in accomplishing this? Any recommendations?
select lv_urspwd
=REQUERY('lv_urspwd')
llSavePwd = .f.
IF _tally = 4 &&Max number of passwords have been captured as changes. Need to capture the oldest password and update that record with the new password
GO TOP &&If there are 4 passwords for this users already, update the latest password which should be the TOP record
replace urspwd_rec WITH oPro.encript(ALLTRIM(ThisForm.Emp_Pwd_Txt.Value))
replace usrpwd_date WITH DATE()
ELSE &&this must be a new employee entry
INSERT INTO lv_urspwd (fk_emp_id, urspwd_rec, usrpwd_date) ;
VALUES (oVar.fk_user_id, oPro.encript(ALLTRIM(ThisForm.Emp_Pwd_Txt.Value)), DATE())
ENDIF
SELECT lv_urspwd
DO WHILE llSavePwd = .F.
llsavePwd = TABLEUPDATE(1,.t.)
IF llSavePwd = .F.
WAIT WINDOW 'Still attempting to save record....please wait ' TIMEOUT 8
LOOP
ELSE
EXIT
ENDIF
ENDDO
Thanks in Advance.
J. Turner