In this demo Access Relational Database Application, I used one of the arguments for the DoCmd.OpenForm action to change the Data Mode for a single form.
Here's the full line of code, taken from two different procedures:
DoCmd.OpenForm FormName:="frmHousehold", View:=acNormal, DataMode:=acFormAdd
which runs from the Click Event of one Command Button.
DoCmd.OpenForm FormName:="frmHousehold", View:=acNormal, DataMode:=acFormEdit
which runs from the Click Event of the other Command Button.
Two Command Buttons Open One Form in Two Different Data Modes |
This is a very simple illustration of the re-use of objects. Instead of creating two different objects--add and edit forms in this case--to do two very similar tasks, we re-use the same object but vary the way it is used. Because adding records to a table, and editing records in that same table are almost identical tasks; it's obvious that we can simplify the Access Relational Database Application this way.
This is a simple example of a much broader set of design principles and practices. If you want to learn more, here's an excellent YouTube video by Phillip Steifel.