lacampeona
Registered User.
- Local time
- Today, 20:01
- Joined
- Dec 28, 2015
- Messages
- 392
Hello experts
I manage to write something by myself...
now I need your opinion if what I make is correct or not?
I have some validation funcion in module...
What i Want is that.
1. user opens and close the form...nothing happen..no saving records
2. users open the form and starts to write into the field..then he suddely say ohh i dont want to save it..i will close.. i want the form close aksing him if he want to save..if he say yes..then validation funcion is called and user receive the message that he must enter all field..if he say no..then form close..if he say yes then he must enter all the field..he can exit the form?
i read a lot the forum and all experts say that validation rule must be used in form before update event? can somebody say me how to write that?
now i am using validation rule on button save and on buttton close.
Do you think that is better to delete the button save and only to have the button close and the validation rule on the before update on the form? hmmmmmm
can somebody show me example how he would write the code and where? on save button? on close button? or all in the before update on the form?
thanks to all
I manage to write something by myself...

now I need your opinion if what I make is correct or not?

I have some validation funcion in module...
What i Want is that.
1. user opens and close the form...nothing happen..no saving records
2. users open the form and starts to write into the field..then he suddely say ohh i dont want to save it..i will close.. i want the form close aksing him if he want to save..if he say yes..then validation funcion is called and user receive the message that he must enter all field..if he say no..then form close..if he say yes then he must enter all the field..he can exit the form?
i read a lot the forum and all experts say that validation rule must be used in form before update event? can somebody say me how to write that?
now i am using validation rule on button save and on buttton close.
Do you think that is better to delete the button save and only to have the button close and the validation rule on the before update on the form? hmmmmmm
can somebody show me example how he would write the code and where? on save button? on close button? or all in the before update on the form?
thanks to all
Private Sub btnClose_Click()
If ValidateRequired(Me, "aaaa") Then
Me.Undo
DoCmd.Close acForm, Me.Name
Exit Sub
End If
If MsgBox("bbbb." & vbCrLf & _
"cccc?", vbYesNo, "Confirm") = vbYes Then
If Not ValidateRequired(Me, "aaaa") Then Exit Sub
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name
Else
Me.Undo
MsgBox "dddd.", vbInformation, "Confirm"
DoCmd.Close acForm, Me.Name
End If
End Sub