Prevent submission of data to database with a macro

My apologies. I am using Before record action event.

I just tested on:

Version: 7.2.5.2 (x64) / LibreOffice Community
Build ID: 499f9727c189e6ef3471021d6132d4c694f357e5
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

and both MsgBox and Print worked.

I agree, that in at least Win 10 this does not work for Before submitting.

before_Submission is not the only deaf listener. Things are severely broken in many places. And no, returning False does not work with before_RecordAction. I really tried. The return value of a function makes no difference. My macro handles before_RecordAction with a Sub. It tests if the calling object is a form controller, prompts for a user confirmation and then it does nothing to allow the record action or performs the undo action in order to reject the action. A record action is always one of SQL INSERT, UPDATE or DELETE.
Rejection triggers an SQL error. This error does not open the IDE editor. It is more like a confirmation message than a runtime error. When you assign the form’s “Error occured” event to a blank routine, this error message is supressed.

Drat! wish I would have thought to try “Before record action”. :brick: I’ll try that and see if I can get away with rolling back to my previous version (7.0.6.2).

Try this sample >
BfrRA.odb (13.3 KB)
.
The accept/reject is based upon field COLOR2. Something in field will move to next record and if empty will stay on record. Code is rough and has issues but shows the functionality.

Unfortunately, “Before record action” is not a good enough substitute for “Before submitting”. It prevents navigation, whereas I need to only prevent submission. :sob:
I guess it’s back to the drawing board with the MySQL Trigger. Anyone know how to make my “CREATE TRIGGER” statement above work or what’s wrong with the syntax right before the beginning of line 5?

Still going to be a problem. In my test changed your IS NULL to = '' and to some degree it works.
Here is the trigger which worked (used my table & field):

CREATE TRIGGER partnos_prevent_no_enteredby
BEFORE INSERT ON partnos
FOR EACH ROW
BEGIN
	IF NEW.enteredby = '' THEN
		SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'The Entered By filed must be filled in before submission.';
	END IF;
END

but note this only displays the message and does not clear the record. You are stuck there until it is corrected or entry undone.

Tested on Ubuntu 20.04 with MySQL v8.x