Forum Discussion

GraemeC_55's avatar
GraemeC_55
Copper Contributor
Mar 22, 2021

MA Accesss save processes

Hello,

I will apologise ahead if this topic has been covered elsewhere. :flushed:

I have an MS Access car club membership project, with several tables, that displays basic member information in a main form with properly functioning navigation (first, last, next, previous) buttons, several labels and text boxes, and a tabbed sub form with each tab containing another sub form containing various labels and text boxes that display categorised information (from different tables) relevant to a member.  

My 2 questions at the moment are: -

  1. Should I have just 1 save button (preferred option) on the main form to save any changes on main form or any of the other tab sub forms or do I need to have a save button on each tab sub form and
  2. What would be the most efficient code for doing either option.

I used to work with Access some 15 or more years ago but have forgotten most of the technical side of things. The changes between Access then and now are quite considerable and I have a lot to re-learn.

Thanks in advance for any help you may give.

Cheers,

Graeme.

  • GraemeC_55 

    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's avatar
    George_Hepworth
    Silver Contributor

    GraemeC_55 

    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's avatar
      GraemeC_55
      Copper Contributor

      George_Hepworth 

      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

  • repuestos's avatar
    repuestos
    Copper Contributor
    Hell. Every time I modify a contact in Acces a window comes out : The "contact list" object is not open

Resources