|Figure1 (above): The Switchboard with Command Buttons |
to open frmEmployees.
|Figure 2: Form Design for frmEmployees. |
Note the label containing the text "Instructions": this text is
dynamically reset as the form opens.
|Figure 3: The IntelliSense feature of the VBA Editor will|
help when you come to enter the DoCmd.OpenForm parameters.
- Create the Switchboard Form with two Command buttons - ctlNew and ctlEdit.
- Add code to each of the command buttons which opens frmEmployees in the desired DataMode and with the corresponding label caption for adding or editing.
- Create frmEmployees along with its underlying data source (ie an employees table). The form should have a label control (lblInstuctions), and text boxes/combo boxes for each of the fields. NB for the purposes of this exercise it does not particularly matter what the fields are.
- Add the relevant code to the OnOpen Event of frmEmployees. This is going to read the value of the forms OpenArgs Property, which is set when the user clicks one of the two command buttons on the switchboard. Then, depending on what that value is, display the appropriate caption for lblInstructions.
|Figure 4: frmEmployees for Editing.|
|Figure 5: frmEmployees for Adding (DataEntry).|