Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO errors from Excel to Access Table 1

Status
Not open for further replies.

DYM03

Technical User
Mar 6, 2003
28
US
I am trying to get insert the value of a cell into a database table but when I enter a line of code in the SQL insert parameter such as the line EmpName is set equal to I get an error. How can I get the value of the cell to go into the table and not what I have named the field.

Sub AppendFile()

Dim db1 As Database
Dim rstEmployees As DAO.Recordset
Dim EmpName As String


EmpName = Range("EMPLOYEE_NAME").Value
Set db1 = OpenDatabase("C:\Documents and Settings\dmitchell\My Documents\Employee Time.mdb")

Set rstEmployees = db1.OpenRecordset("EmployeeTime", dbOpenDynaset)

db1.Execute "INSERT INTO EmployeeTime " _
& "(EMPLOYEE_NAME) VALUES " _
& "('[EmpName]');"

db1.Close
'rstEmployees.Update
'.AddNew
'rstEmployees.Fields("Last Name") = EmpName
 
Thank you so much for your help Chance! That worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top