How is my recordset code syntax wrong??

  • Thread starter Thread starter Jamie Loren
  • Start date Start date
J

Jamie Loren

I am using this code successfully...
rs.AddNew "Field1", "12345"

But I can't seem to figure out the syntax when I have multiple fields.
For example, the following code fails...

rs.AddNew "Field1,Field2" & "12345,67890"

What am I doing wrong?
 
use this instead

rs.AddNew
rs!Field1 = "12345"
rs!Field2 = "67890"
....
rs.Update
 
Jamie Loren wrote in message said:
I am using this code successfully...
rs.AddNew "Field1", "12345"

But I can't seem to figure out the syntax when I have multiple
fields.
For example, the following code fails...

rs.AddNew "Field1,Field2" & "12345,67890"

What am I doing wrong?

For ADO recordsets, you can pass fields and values as arrays

rs.AddNew array("field1", "field2"), array("12345", "67890")

But if you're using a such construct, perhaps consider using a query
in stead?

strsql = "insert into mytable (field1, field2) values (12345, 67890)"
yourconnection.execute strsql, , adcmdtext + adexecutenorecords
 

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

Back
Top