Forum Discussion
GraemeC_55
Mar 22, 2021Copper Contributor
MA Accesss save processes
Hello, I will apologise ahead if this topic has been covered elsewhere. I have an MS Access car club membership project, with several tables, that displays basic member information in a main for...
- Mar 22, 2021
The answers to your questions are, 1) not necessary. and 2) Me.Dirty = False
That said, there are a few additional things to consider beyond the surface questions.
First, using bound forms, which I assume these are, Access will always save the current record when the form to which it is bound loses focus. In other words, if you are adding or editing a record in the main form, moving the cursor to one of the subforms (i.e. changing focus from the main form to the sub) automatically saves the current record in the main form. No additional saving needed. That can be either desirable or undesirable depending on othe factors, but it is the baseline default behavior.
Second, this is true, as noted above, of both Main forms and Sub forms when they are bound to tables (or to queries), so again, moving the focus from any one of the subforms to either the main form or to another subform automatically saves that subform's current record.If you REALLY want to do your own saves, of course, you can.
A command button on a form with this code behind does the trick:
Private Sub cmdSAVEME_Click()
Me.Dirty = False
End Sub
George_Hepworth
Mar 22, 2021Silver Contributor
The answers to your questions are, 1) not necessary. and 2) Me.Dirty = False
That said, there are a few additional things to consider beyond the surface questions.
First, using bound forms, which I assume these are, Access will always save the current record when the form to which it is bound loses focus. In other words, if you are adding or editing a record in the main form, moving the cursor to one of the subforms (i.e. changing focus from the main form to the sub) automatically saves the current record in the main form. No additional saving needed. That can be either desirable or undesirable depending on othe factors, but it is the baseline default behavior.
Second, this is true, as noted above, of both Main forms and Sub forms when they are bound to tables (or to queries), so again, moving the focus from any one of the subforms to either the main form or to another subform automatically saves that subform's current record.
If you REALLY want to do your own saves, of course, you can.
A command button on a form with this code behind does the trick:
Private Sub cmdSAVEME_Click()
Me.Dirty = False
End Sub
GraemeC_55
Mar 23, 2021Copper Contributor
Hi George,
Thanks for your help. That last bit of code works nicely.
Have to add a few formatting bits and pieces but that is only trial and error to get them working.
Cheers,
Graeme