Cancel INSERT in a BeforeInsert Trigger
Hi all,
I have the following code in the beforeinsert trigger of a company table:
Code:
// Trigger onbeforeinsert for table company
if reccount() <= 1
return .t.
else
messagebox("Only one company can be created!")
delete
return .f.
endif
What I want is for a new record not to be created if one already exists. In the above code the message gets displayed but a new record still get inserted which i have to delete manually as the above code does not work.
The insert button of a form section is used to create the new record.
How do i fix this?
Best Regards