Saving Records

R

Randy

Hello...was wondering if there is a way or a command that "would not" save
data when a form is closed?
 
N

NetworkTrade

presuming you mean data that was in the process of being entered into the
form....this is refered to "dirty"

you can look up that search word in the Form area of this site and see
instructions to go either way with this....

in many cases the issue is just the opposite...users close a form before
exiting a field...and so the data is not saved...
 
R

Randy

Kool...thanks....I actually need data not to save if a certain field does not
meet a certain criteria when the form is closded....I will lok into that...

Thanks again..
 
J

John W. Vinson

Kool...thanks....I actually need data not to save if a certain field does not
meet a certain criteria when the form is closded....I will lok into that...

Use the Form's "Before Update" event to check the validity of the data. If
it's invalid, set the Cancel operand to True. The code might look like

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!certainfield > 100 Then
MsgBox "certainfield must be <= 100!", vbOKOnly
Cancel = True
End If
End Sub
 
Top