Object Required for DoCmd

  • I am trying to execute a SQL statement in ACCESS from Excel. I keep getting an error statement around the DoCmd line stating: "Object Required". Any insight would be helpful.



    Code
    Dim conn As ADODB.Connection
        Dim rs As New ADODB.Recordset
        rs.ActiveConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\Users\Philosophaie\Documents\Banking & Bills\a Chase.accdb;"
        thisSQL = "INSERT INTO [a Chase Table] VALUES [null],[" & accDate & "],[" & accDesc & "],[" & accAddSub & "],[" & accRunTotal & "]"
        DoCmd.RunSQL thisSQL
  • Re: Object Required for DoCmd


    Hi,



    Sorry I don't have Excel home so I can't test this but, based on that snippet, the issues are:
    You are defining a connection but then not using it.
    You are defining a new recordset and then assigning the active connection of that record set, but again, you are not doing anything with it.


    DoCmd is an item of the access object model, but you have not declared that.


    I would suggest somehting like:

  • Re: Object Required for DoCmd


    Really you should start a new thread for the new question re the insert statement, on the face of it it looks fine but it depends a lot on the make up of the "a Chase Table" and the data that you have in the variables.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!