Experts Exchange connects you with the people and services you need so you can get back to work.
Improve company productivity with a Business Account.Sign Up
Dim cn As Object
Dim strQuery As String
Dim Name As String
Dim Number As String
Dim myDB As String
Name = Worksheets("Sheet1").Range("A2").Value
Number = Worksheets("Sheet1").Range("B2").Value
'myDB = "C:\Users\username\Documents\EMP.accdb"
myDB = "replace with the fully qualified path to your Access Db"
Set cn = CreateObject("ADODB.Connection")
.Provider = "Microsoft.ACE.OLEDB.12.0" 'For *.ACCDB Databases
.ConnectionString = myDB
strQuery = "INSERT INTO Employees ([Name], [Number]) " & _
"VALUES (""" & Name & """, " & Number & "); "
Set cn = Nothing
Open in new window
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.