Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2001
    Location
    Naperville, Illinois, USA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ADO Adding Recs (A2003 (as A2K))

    I am converting over to ADO from DAO for recordsets. I have a simple application where I want to add a record to a table from inside of a form.

    Private Sub cboProjectID_AfterUpdate()
    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset
    rst.Open "tblProjNotes", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    With rst
    .AddNew
    .Fields("ProjectID") = Me.cboProjectID
    .Fields("projectnotes") = Me.TempNotes
    .Fields("AddDate") = Now
    .Update
    End With
    rst.Close

    End Sub

    When I run the code thru the Update action, I get the following error message:

    run time error '-2147217900(80040e14)'
    Invalid SQL statement: expected 'DELETE', 'INSERT", PROCEDURE"....

    I have the following reference libraries checked:

    Visual Basic for Application
    Microsoft Access 11.0 Object File
    OLE Automation
    Microsoft ActiveX DataObjects 2.1 Library
    Microsoft DAO 3.6 Library

    If I remove the DAO reference, then I get a different error on the After Update action.

    I would appreciate any help you can give me!

    Thanks,

    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ADO Adding Recs (A2003 (as A2K))

    You must tell ADO that you're opening a table:

    rst.Open "tblProjNotes", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdTableDirect

    ADO is rather finicky!

  3. #3
    Star Lounger
    Join Date
    Apr 2001
    Location
    Naperville, Illinois, USA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ADO Adding Recs (A2003 (as A2K))

    That did the trick! Thanks a bunch, I was getting frustrated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •