Code to add record to a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I didn't use acess forms for a while and I totally forgot how
to add records using the command button in a form. I would like to get that
code.
Any help really appreciated.
 
Use the Command Button Wizard. Just drag a new button to your form, the
Command Button Wizard starts. The second option in the list is Record
Operatoions. The first item in the next list is Add New Record. click Next,
choose a lable or picture for your button, click next choose a name
(cmdAddNew) for example, and click Finish: The following code results:


Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click
DoCmd.GoToRecord , , acNewRec

Exit_cmdAddNew_Click:
Exit Sub

Err_cmdAddNew_Click:
MsgBox Err.Description
Resume Exit_cmdAddNew_Click
End Sub
 
Back
Top