Hello James, I think for using any forms/running any quires, the access has to be opened.
Also I think Connection method only used to share the data from the table/queries. Try the following code. Sub MyOpenDb() Dim appAccess As Object Set appAccess = CreateObject("Access.Application") appAccess.OpenCurrentDatabase ("D:\XXX\ABCD.MDB") appAccess.Visible = True appAccess.docmd.openquery "XXXXXXXX" appAccess.Quit End Sub Revert back, if any comments, issues Regards, Kishan Reddy, K On Sep 14, 3:31 pm, "ja...@macstop.co.uk" <ja...@macstop.co.uk> wrote: > Hi, > > I have posted this on the access group too, it can't really be > classified as one or the other, but it's driving me mad, can anyone > help. > > I have an Access 2010 database, which I have saved as .mdb. (ie not > accdb) > > It has an update query in, which takes 2 string parameters. When I run > it from Access it works fine - asks me for the 2 parameters then > updates the table accordingly. > > However, I am trying to run it from Excel VBA. At first I thought the > issue was the parameters, so I created another update query which > takes 0 parameters. The continual error I get is 'Operation must use > an updateable query'. > > It goes without saying that I can connect to the database, and I can > run normal Select statements - anyone got any ideas? Code below: > (obviously the execute line is the one that gives the error). > > Function RunUpdateQuery(objConn As ADODB.Connection) > Dim objCommand As ADODB.Command > > Set objCommand = New ADODB.Command > > With objCommand > .ActiveConnection = objConn > .CommandType = adCmdStoredProc > .CommandText = "qryTest" > .Execute > End With > > End Function -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel