Solved

Triggering an Access macro from within a Visual Basic - exe

Posted on 2001-06-14
3
176 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

808 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