709-218-7927 The Landfall Garden House 60 Canon Bayley Road CANADA A0C 1B0 |
---|
Duplicating an Existing Record
In this lesson we will develop the program code to duplicate the current record of our table; Access VBE will assist us in most of the work.
Create a new Command Button on your form, as before, but this time when the Wizard pops up, choose "Record Operations" from the left-hand pane and choose "Duplicate Record" from the right-hand pane. Elect to use a text caption, and abbreviate the suggested text to "Duplicate" - that's all we need to know about this button. We will call this button "cmd_DuplicateRecord".
When you inspect the generated code you should see this:
Private Sub cmd_Duplicate_Click() On Error GoTo Err_cmd_Duplicate_Click DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append Exit_cmd_Duplicate_Click: Exit Sub Err_cmd_Duplicate_Click: MsgBox Err.Description Resume Exit_cmd_Duplicate_Click End Sub
The essential 3 lines are the "DoCmd.DoMenuItem" lines.
If you have placed the "Duplicate" Command Button near your previous "Add" Command Button, now would be a good time to align them (choose Format, Align) and perhaps to make them the same size (Choose Format, Size, Fit To Widest).
7092187927 CPRGreaves@gmail.com Bonavista, Friday, December 04, 2020 5:52 PM Copyright © 1996-2020 Chris Greaves. All Rights Reserved. |
---|