Access query in 2010

Posted on 2012-09-10
Last Modified: 2012-09-14
1. I am new to My question is: can you run querys from an access database 2010 from , if so can someone explain to my how?

2. Can you do the same with macros? if so how.

3. I will need to do the following with-in
Add a record
update record
delete record

I will need some examples. Please help.
Question by:Poppygb
    LVL 12

    Expert Comment

    There are 2 primary ways that you can interact with an Access db from .NET.  1) Use ADO.NET to run SQL statements against the db as a backend. 2)  Use Access automation to run Access as an application an have the Access application do the queries, etc.

    Option 1 is generally preferred  when possible.  However for doing very Access specific things like running Access macros, interacting directly with Access forms and reports you need option 2.

    For adding, updating, and deleting records option 1 is would usually be the way to go.

    There are many specific examples of interacting with databases of all sorts using VB.NET and ADO.NET.  If you could give a little more info on what you are trying to do it would be helpful.  For instance, web or windows app?  Do you need to see/manipulate the data you are updating/changing?
    LVL 84

    Accepted Solution

    The only way to run a Macro would be through automation. I'd strongly advise against doing that, and instead move your Macro logic to .NET code (otherwise what's the point of doing this in .NET?).

    Author Closing Comment

    I wish I could get some code examples or a good book that goes more into detal.
    Other wise GOOD WORK
    LVL 84
    Here's a link on automating Access from .NET:

    You need a Reference to the Access library, and then you do this:

    Dim oAccess As Access.Application
    oAccess = New Access.ApplicationClass
    oAccess.OpenCurrentDatabase("Path to your db")

    '/ now use the oAccess object:
    oAccess.Docmd.RunMacro "YourMacroName"

    '/ be sure to close the object:
    oAccess = Nothing

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now