Insert data into a table

A

Ac

Hi,

I would like to insert the data into the Fields (FixedRate, VolumePumped,
TimeStep, MudIntoAnnulus, GasIntoAnnulus) in a recode (row) of a table named
ResultData, all data are calculated (A7, B7, C7, D7, E7) and have the data
type as Double; following is the code for the inserting data into the recode,
but I got the error message said “Syntax error in INSERT INTO statement.
Could someone point out what is wrong for the code? Or should I use ADDNEW
instead of INSERT INTO? What is the ADDNEW syntax? Thanks!

Dim rs As DAO.Recordset
Dim fld As DAO.Field

Set rs = CurrentDb.OpenRecordset("ChartData")

For Each fld In rs.Fields


DoCmd.RunSQL "INSERT INTO ResultData (FixedRate, VolumePumped, TimeStep,
MudIntoAnnulus, GasIntoAnnulus,) VALUS ( & A7, B7, C7, D7, E7 & )"


Next fld
 
J

John Spencer

Extra comma at end of field list
, Word "Values" misspelled
, Values of variables improperly concatenated into string

DoCmd.RunSQL "INSERT INTO ResultData " & _
"(FixedRate,VolumePumped, TimeStep, MudIntoAnnulus, GasIntoAnnulus)" & _
" VALUES (" & A7 & ", " & B7 ", " & C7 & "," & D7 & ", " & E7 & ")"

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
A

Ac

Thank you very much for your help!

John Spencer said:
Extra comma at end of field list
, Word "Values" misspelled
, Values of variables improperly concatenated into string

DoCmd.RunSQL "INSERT INTO ResultData " & _
"(FixedRate,VolumePumped, TimeStep, MudIntoAnnulus, GasIntoAnnulus)" & _
" VALUES (" & A7 & ", " & B7 ", " & C7 & "," & D7 & ", " & E7 & ")"

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top