469,086 Members | 1,133 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,086 developers. It's quick & easy.

adding new record using VBA into existing access database

2
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.OpenRecordset("N-MATTE")

rstNew.AddNew
rstNew("DATE").Value = Me.txtDate.Value
rstNew("CLIENT").Value = Me.txtClient.Value
rstNew.Update

End Sub
Sep 18 '16 #1
2 889
5236
2
To be more specific, I would like the record id to be auto-generated without having to add it by the form.
Sep 18 '16 #2
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.
Sep 19 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Jon S via DotNetMonster.com | last post: by
14 posts views Thread by SimeonD | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.