416-621-9348 cgreaves@chrisgreaves.com Visit www.ChrisGreaves.com for this image! Chris_GEDC1894_Head (Small).JPG
Home Services Products

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".


Loading

Toronto and Mississauga, Sunday, December 05, 2010 3:20 PM

Copyright © 1996-2010 Chris Greaves. All Rights Reserved.