Solved

Triggering an Access macro from within a Visual Basic - exe

Posted on 2001-06-14
3
172 Views
Last Modified: 2013-11-25


I have the following situation :
An Access database residing on a server.
The same Visual Basic Exe is installed on several client PC's , the exe reading the data from the Access database.
Now i want to make a button on my VB-exe form to launch a macro , defined in the Access Database.
I tried it using the Shell command , but since i don't have Access installed on the client PC's ( only on the server ) , it gives an error.

Is there a way to do it using OLE-automation ? The Database object doesn't contain a method to launch macro's , only to execute Queries.
0
Comment
Question by:Steamer
  • 2
3 Comments
 
LVL 4

Expert Comment

by:RichW
Comment Utility
Try this:  Set a reference to the Microsoft Access 8.0 Object Library.


Public Sub RunMacro()

Dim acApp As Access.Application
Dim strDBPath As String

   Const DB_PATH As String = "C:\Db1.mdb"
   Set acApp = New Access.Application
   With acApp
      .OpenCurrentDatabase DB_PATH
      .DoCmd.runmacro "Macro1", 1, 1
   End With
   acApp.Quit
   Set acApp = Nothing

End Sub
0
 

Author Comment

by:Steamer
Comment Utility
Tried the above mentioned code , but i still got the error :

Microsoft Access : ActiveX component can't create object.

This is still because access isn't installed on the computer where the VB application is running.
for a test i installed access and the application is running fine.
Due to the licensing , i really need a solution which would be able to work without installing Access since the application runs on several computers.
Any options to bypass this ?
0
 
LVL 4

Accepted Solution

by:
RichW earned 100 total points
Comment Utility
Try compiling the application, and running a setup package.  VB should grab the files needed from the Access library and add them to the setup package CAB file.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

10 Experts available now in Live!

Get 1:1 Help Now