I use
DoCmd.RunCommand acCmdSaveRecord
to save but Im not sure how this actually works. Does it save every unsaved change? Or does it save everything no matter if it was changed or not? Or does it only save the current form? Whats about releated unsaved changes in other forms? Or does it function in any other way? Is there any offical documentation to this function?
It saves the current record of the active form. It is the same as clicking on the record selector.
If the current record is not currently being edited (not "Dirty"), then nothing happens.
If you want better control, especially when dealing with subforms, I suggest to use the Form.Dirty
property instead. With this you can explicitly address the form you want to save.
To save the current record in a form module (only save when needed):
If Me.Dirty Then
Me.Dirty = False
End If
To save the record in any form
With Forms!myForm
If .Dirty Then
.Dirty = False
End If
End With
Or a subform
Forms!mainForm!SubFormControl.Form.Dirty = False
This is much clearer and better IMO. I have stopped using DoCmd.RunCommand acCmdSaveRecord
completely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With