6/15/10

Saving a record through code

If you need to force a record to be saved, normally in order that you can then use that record for something, such as being printed in a report, then you have three options available:

  • Using a DoMenuItem method. These have now been effectively replaced in Access 97, and are not automatically replaced when a database is converted between versions.

  • Using DoCmd.RunCmd acCmdSaveRecord

  • Using the Dirty property of the form. This is the recommended method, as you can firstly only force a save if needed, and secondly, you are guaranteed of ensuring that the correct form has its data saved:

    Private Sub cmdSave_Click()
    If Me.Dirty=True Then Me.Dirty=False
    End Sub


http://www.applecore99.com/frm/frm025.asp

No comments: