Experts Exchange connects you with the people and services you need so you can get back to work.
'This is sample code for if you want to insert FROM Excel instead of in Access
Private Sub CommandButton1_Click()
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("DriveLetter:\DirectoryName\DirectoryName\DatabaseName.mdb")
'open the database
Set rs = db.OpenRecordset("TABLENAME", dbOpenTable)
.AddNew ' create a new record
'add values to each field in the record
.Fields("TableFieldName1") = Range("B" & 4).Value
.Fields("TableFieldName2") = Range("B" & 5).Value
.Fields("TableFieldName3") = Range("B" & 6).Value
.Fields("TableFieldName4") = Range("B" & 7).Value
.Fields("TableFieldName5") = Range("B" & 8).Value
.Fields("TableFieldName6") = Range("B" & 9).Value
.Fields("TableFieldName7") = Range("B" & 10).Value
.Update ' stores the new record
Set rs = Nothing
Set db = Nothing
Open in new window
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $25.00.
Premium members get this course for $159.20.
Premium members get this course for $389.00.
Premium members get this course for $108.00.