Data validation before update.

Poco_90

Registered User.
Local time
Today, 13:22
Joined
Jul 26, 2013
Messages
87
I am trying to figure out how to validate some data if a user chooses to save a record. On my form I have this as my before update event

Code:
 If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
   Me.Undo
My question is if the users says yes, how to I incorporate the validation below?

Code:
If IsNull(Me.Serial) Then
        MsgBox "Please Scan a Serial Number!", vbOKOnly
I have searched and can't seem to find a solution. I can get the validation to pop up when a field is missing, but instead of aborting the save, the incomplete record saves.

Also, I would like the form to remain open if a user chooses to save the record but no matter where I place this the form still closes
Code:
DoCmd.OpenForm "frmWareIN", acNormal, "", "", , acNormal
I don't understand what is happening on the yes event, and that is where my problem lies.
Thanks in advance,
Poco
 
Last edited:
The easier way to make your Serial field to be required is to set it in the table design. Or to set the Validation Rule & Text in table design.
 
Minty, James,
Thanks for taking the time to reply to my question. I ended up changing the filed to be required in the table design, so it has crudely got me started.

I think James suggestion with a validation rule in the table design might be the easiest option for me.
Many thanks,
Poco
 

Users who are viewing this thread

Back
Top Bottom