ADO Recordset - AddNew

jocooper

Limp Gawd
Joined
Mar 28, 2003
Messages
367
I am trying to add a new record to my database, and I get an error because of the field named "key" - I believe because its a reserved word.
Whenever I hit the update statement, it reports a syntax error. If I comment out the line that sets the value of the field named "key" everything works.

Is there a way around this other than changing the field name?

Code:
   Set rs = CreateObject("ADODB.Recordset")
    rs.LockType = 2
    rs.Open "smNoteHeader", Form1.conn
    
    With rs
        .AddNew

        .Fields("key").Value = "12134"
        .Fields("topic").Value = "General"
        .Fields("NoteID").Value = "500"
        .Fields("NoteSubject").Value = "New Subject12"
        .Fields("Options").Value = "1;1;1;0"
        .Fields("Options2").Value = "1;0;0;0"
             
        .Update
    End With
    rs.Close
 
You might try using ordinal numbers instead of field names, ala:

Code:
.Fields(0).Value = "12134"
.Fields(1).Value = "General"

...
 
Back
Top