Solved Validate required and close form (1 Viewer)

lacampeona

Registered User.
Local time
Today, 22:34
Joined
Dec 28, 2015
Messages
234
Pat i am trying to implent your idea...

i manage to put all..
but where is now my validation rule?
i have to put in on the save button? becouse on the before update is now another code?

hmmmm
mabye i am lost..sorry

If ValidateForm(Me, "required") = False Then
cancel = True
End If

thanks
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:34
Joined
Feb 19, 2002
Messages
36,974
It goes in the BeforeUpdate event.

The save button sets the flag and then saves the record. NO OTHER code goes here. Put your call to the validation procedure in the BeforeUpdate event AFTER you have checked the SaveYN flag. Once you know they have clicked the button, continue into the validation.
 

lacampeona

Registered User.
Local time
Today, 22:34
Joined
Dec 28, 2015
Messages
234
sorry mistake
you mean that way..after
If SaveYN = True Then
SaveYN = False
Else
cancel = True
MsgBox "Please use the Save Button if you want to save the record.", vbOKOnly
Exit Sub
End If
If ValidateForm(Me, "required") = False Then
cancel = True
End If
End Sub
 

lacampeona

Registered User.
Local time
Today, 22:34
Joined
Dec 28, 2015
Messages
234
if I am not crazy today...this is workingggggggggggggg workingggggggggggg

that is what i want...i have to think like crazy user what he can click and to prevent all that
🕺🕺🕺🕺🕺🕺🕺🕺🕺🕺🕺🕺🕺
thank you very muchhhhhhh Pat and also Minty for your advices
:love::love::love::love::love::love::love::love::love::love::love:
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:34
Joined
Feb 19, 2002
Messages
36,974
what if you close the form and Don't want to save the record?
If the code has been implemented correctly, the user will get a message telling him to save the record or giving him the option to cancel
 

lacampeona

Registered User.
Local time
Today, 22:34
Joined
Dec 28, 2015
Messages
234
Hello

yes the code is working in correct way. User get message ,he can choose what he want to do.

the user will get a message telling him to save the record or giving him the option to cancel
 

Users who are viewing this thread

Top Bottom