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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into help

Status
Not open for further replies.

luismagally

IS-IT--Management
Jan 12, 2005
21
PR
Hi, I'm trying to append some values to a table in access using the insert into sql statement, but keep geting syntax errors. The values to be appended come from value in a form: i.e. date1.value, hour1.value, etc. What is the correct syntax to append this values to a table in access, or do I have to create a temp table and append from there?

Thanks
 
This is the code I've tried so far:

insertSQL = "INSERT employeename.value, project_id1.value, discipline_a.value, date_a.value, hour_a1.value, date_a2.value, hour_a2.value, date_a3.value, hour_a3.value, date_a4.value, hour_a4.value, date_a5.value, hour_a5.value, date_a6.value, hour_a6.value, date_a7.value, hour_a7.value, date_a8.value, hour_a8.value, date_a9.value, hour_a9.value, date_a10.value, hour_a10.value, date_a11.value, hour_a11.value, date_a12.value, hour_a12.value, date_a13.value, hour_a13.value, date_a14.value, hour_a14.value INTO timesheet"

DoCmd.RunSQL insertSQL

also tried:


insertSQL = "INSERT INTO timesheet (employeename.value, project_id1.value, discipline_a.value, date_a.value, hour_a1.value, date_a2.value, hour_a2.value, date_a3.value, hour_a3.value, date_a4.value, hour_a4.value, date_a5.value, hour_a5.value, date_a6.value, hour_a6.value, date_a7.value, hour_a7.value, date_a8.value, hour_a8.value, date_a9.value, hour_a9.value, date_a10.value, hour_a10.value, date_a11.value, hour_a11.value, date_a12.value, hour_a12.value, date_a13.value, hour_a13.value, date_a14.value, hour_a14.value)"

DoCmd.RunSQL insertSQL


Where timesheet is the table into which I try to insert the values.

Thanks
 
In order to make an insert, you must specify the target table, the columns to be inserted, & either the values or related columns to select from. In your case you have not specified the target columns or the VALUES clause, hence the syntax errors:

Code:
"INSERT INTO timesheet (EmployeeName, ...) " & _
" VALUES ('" & me.employeename & "',...)"

If the value is text based, enclose in single quotes (''). If the value is a number, omit them.

James Goodman MCSE, MCDBA
 
And for DateTime values, enclose in dash (#)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top