Anybody who has developed with VBA and FastForms long enough has most likely run into the following error message.

I cannot tell you exactly why this error occurs, because I’ve never received an answer from support. I know the surest way to trigger it is to attempt to error check fields during the SAVE or BEFORESAVE events with VBA when using FastForms.
For example, if you use the following VBA code on the Inventory Screen (INV), you will not receive an error no matter how many times you interrupt the saving process. Keep in mind that I have used VBA to first create the txttest text box on my form on the INIT event before calling this code.
Public Function BEFORESAVE() As Boolean
If Trim(ThisForm.m2mpageframe1.page6.txttest.Value) <> "1" Then
MsgBox ("Enter 1 please")
ThisForm.m2mpageframe1.page6.txttest.SetFocus
BEFORESAVE = False
Exit Function
End If
BEFORESAVE = True
As I said, this works. However when you use FastForms with the following code, it won’t.

FastForms text box and resulting message box.
Public Function BEFORESAVE() As Boolean
If Trim(ThisForm.m2mpageframe1.page6.txttest.ctltarget.Value) <> "1" Then
MsgBox ("Enter 1 please")
BEFORESAVE = False
Exit Function
End If
BEFORESAVE = True
Up until fairly recently, that error message was at the top of my list of annoyances. When a manager asked me if I could force users to enter the “right” values in my fields, I had to give an unacceptable answer. The answer was that I could either warn them that they had made a mistake, but ultimately allow them to do so, or I could force them to input appropriate information and risk an error like the one shown above. Neither of these options really solved the problem.
However, there is an undocumented event that many (if not all) screens support, which is called VALID. The VALID event, which I suppose is an abbreviation of validation, occurs before the BEFORESAVE event and can reliably interrupt the save process for FastForms. The following code will work repeatedly on the INV screen using the same FastForms text box control.
Public Function VALID() As Boolean
If Trim(ThisForm.m2mpageframe1.page6.txttest.ctltarget.Value) <> "1" Then
MsgBox ("Enter 1 please")
VALID = False
Exit Function
End If
VALID = True
End Function
Feel free to leave comments on this discovery and also let me know if you’ve tested it on other screens with or without success.



I have tested using the VALID() function on the PO form and the SO form and you can use it to prevent the BeforeSave and Save methods from firing by returing a FALSE in the VALID() function. Works great!