Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent form commit

Status
Not open for further replies.

haste

Programmer
Feb 27, 2005
96
0
0
GH
I'd like to know how to prevent a form from saving if a condition is true after a user presses the commit key (F10). I have tried adding this on-commit trigger at the form level but the form gets commited.

Code:
declare
	update_after_approval exception;
  err_txt   VARCHAR2(80) := 'Document is already approved, cannot modify/delete'; 
  al_id     Alert; 
  al_button Number; 

begin
if :LNAH_APPR_DT is not null then 
	-- record already approved
	-- alert user
	-- prevent update
	  al_id := Find_Alert('stop'); 
  Set_Alert_Property(al_id, alert_message_text, err_txt ); 
  al_button := Show_Alert( al_id ); 
  --rollback;
else 
	commit_form;
end if ;
end;
 
Thanx for the help. It worked, I placed the code in the key-commit, key-entqry and key-exit to vet all actions to the form that request a user to save the form. Added this code to key-commit

Code:
declare
	update_after_approval exception;
  err_txt   VARCHAR2(80) := 'Document is already approved, cannot modify/delete'; 
  al_id     Alert; 
  al_button Number; 

begin
if :LNAH_APPR_DT is not null then 
	-- record already approved
	-- alert user
	-- prevent update
	  al_id := Find_Alert('stop'); 
  Set_Alert_Property(al_id, alert_message_text, err_txt ); 
  al_button := Show_Alert( al_id ); 
else 
	commit_form;
end if ;
end;

Thanx heaps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top