Solved

Triggering an Access macro from within a Visual Basic - exe

Posted on 2001-06-14
3
173 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
ID: 6192878
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
ID: 6200077
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
ID: 6202085
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 65
How to compare ms sql hashbytes results within vb6 5 55
Problem to open text file 11 74
VS2015 Redefinition errors 4 29
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

867 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

22 Experts available now in Live!

Get 1:1 Help Now