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

insert into... recordset? 1

Status
Not open for further replies.

solun

Programmer
Apr 1, 1999
55
Hi, all...

I'm learning the SQL statement "Insert Into" today... I've got a bunch of calculations created by a vba script and need to pop the results into a table to be able to create reports off it. Since I've been using a SQL statement to create a recordset to get the original data, i thought using a SQL statement to create a recordset for inserting would work...
Code:
strSQL = "INSERT INTO errors VALUES (" & lid & "," & today & "," & ctapps & ")"
Set rs3 = CurrentDb.OpenRecordset(strSQL)

Runtime error 3219: Invalid operation

So, how am I supposed to do this?

Thanks!

Heidi I. Jones
Ridgerunner Consulting
Questions Answered. Problems Solved.
 
And this ?
CurrentDb.Execute strSQL

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
strSQL = "INSERT INTO errors VALUES (" & lid & "," & today & "," & ctapps & ")"
docmd.runsql(strSQL)
set rs3 = CurrentDb.OpenRecordset(Errors)
 
ah, thanks!

now, how do i account for the autonumber PK field "errorid"? or am I supposed to keep a counter going within my script?


strSQL = "INSERT INTO errors VALUES ("errorid should go here & lid & "," & today & "," & ctapps & ", 1, 1, 1," & teststr & ")"


Heidi I. Jones
Ridgerunner Consulting
Questions Answered. Problems Solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top