Preventing insert, update and deletes



Hello!

I have a security setting giving users access to insert, update or delete
records. I'm trying to implement this in the easyest way. Of cource I can
change the buttons in my DBNavigator but I would prefer to have some common
code for all my tabels. I'w tried to use the ADOQuery.BeforeInsert as
example. When the event triggers I can check if the user has accessright to
add and if not show a message and abort, the only problem is - How do I
abort in this case?

The following code did not work....

Procedure TMyForm.OnBeforeInsert(DataSet: TDataSet);
Begin
If Not AccessAdd Then
Begin
ShowMessage('You do not have access right to create this record!');
ADOQuery.Cancel; // <- What code goes here?
End;
End;

Regards, Mikael



.


Quantcast