totn Access

MS Access 2003: Add new record using VBA code

This MSAccess tutorial explains how to add a new record in a form using VBA code in Access 2003 (with step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, I've created a form and I want to know how to add a new record by using VBA code?

Answer: In your Access form, you could create a button. On the Click event of this button, you could place VBA code to create a new record.

For example:

Private Sub Command1_Click()

   DoCmd.GoToRecord , , acNewRec

End Sub

In this example, we've created a button called Command1. When the user clicks on this button, Access will create a new record and display this new record in the form.