I am looking to run a VB macro in Excel which opens an Access database, opens a table, then paste appends a record to the table. Can anyone give me a hand with the code?
if you add the access object library as a reference in XL and and explicitly refer to Access in you declarations it will be a bit easier as you can work with it as if you were in Access, just replace application with your Access App variable (application is the default for access objects and therefore you dont usually have to type it, but use the object browser to help work out where you need it) to create a an access object explicitly use
Code:
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase ("\path\to\database.mdb")
- which is just the same as what PHV posted except you'll get the auto list of members, i.e. appAccess.DoCmd.RunSQL strUpdateQuery
The other thing you could do is write it all in your access database, add your access db to Excel as a reference and call access db functions from Excel... HTH, Jamie
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.