SET REPROCESS TO 5 SECONDS SET EXCLUSIVE OFF SET MULTILOCKS ON SELE 0 USE CDM05RPM && hope name is correct IF USED("CDM05PRM") .and. !EOF("CDM05PRM") .and. recno("CDM05PRM") > 0 WAIT WINDOW "Last number used was: " + ALLTRIM(STR(MEMLASTWO))+ ". Press anykey to lock record ..." IF RLOCK() WAIT WINDOW "Locked record successfully. Press anykey to get new value..." IF !EMPTY(MEMLASTWO) new_wo = MEMLASTWO + 1 ELSE new_wo = 1 ENDIF REPLACE NEXT 1 MEMLASTWO WITH new_wo REPLACE NEXT 1 MEMLASTRR WITH new_wo unlock ELSE wait window "Unable to lock record to get next wo number. Press anykey..." ENDIF ELSE WAIT WINDOW "Unable to open CRM05RPM. Press anykey..." ENDIF IF USED('CDM05RPM') USE IN CDM05RPM ENDIF