adding new record using VBA into existing access database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 5236
    New Member
    • Sep 2016
    • 2

    adding new record using VBA into existing access database

    Hello guys, I'm new to VBA and trying to create a form for inserting new records into an existing access database, the thing is the database is provided by a third party so I don't have control over it's fields specification. there's already 26705 rows I'd like the insertion of new records to continue in the same sequence, that's the code I've used:
    Private Sub Command19_Click ()

    Dim dbConf As DAO.Database
    Dim rstNew As DAO.Recordset

    Set dbConf = CurrentDb
    Set rstNew = dbConf.OpenReco rdset("N-MATTE")

    rstNew.AddNew
    rstNew("DATE"). Value = Me.txtDate.Valu e
    rstNew("CLIENT" ).Value = Me.txtClient.Va lue
    rstNew.Update

    End Sub
  • 5236
    New Member
    • Sep 2016
    • 2

    #2
    To be more specific, I would like the record id to be auto-generated without having to add it by the form.

    Comment

    • informerFR
      New Member
      • Jun 2016
      • 14

      #3
      Hi 5236

      If you declare an auto number field on a table, this field increments itself automatically when you add a record on this table. Nothing to do.

      Comment

      Working...