709-218-7927

The Landfall Garden House

60 Canon Bayley Road

Bonavista, Newfoundland

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

Adding a New Record

In this lesson we will develop the program code to add a new record to 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 "Add New Record" from the right-hand pane.

Elect to use a text caption, and abbreviate the suggested text to "Add" - that's all we need to know about this button. We will call this button "cmd_AddRecord".

When you inspect the generated code you should see this:

Private Sub cmd_AddRecord_Click()
On Error GoTo Err_cmd_AddRecord_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmd_AddRecord_Click:
Exit Sub
Err_cmd_AddRecord_Click:
MsgBox Err.Description
Resume Exit_cmd_AddRecord_Click
End Sub

The essential line is "DoCmd.GoToRecord , , acNewRec".

709-218-7927 CPRGreaves@gmail.com

Bonavista, Sunday, December 08, 2024 9:30 AM

Copyright © 1990-2024 Chris Greaves. All Rights Reserved.