• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Triggering an Access macro from within a Visual Basic - exe



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
Steamer
Asked:
Steamer
  • 2
1 Solution
 
RichWCommented:
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
 
SteamerAuthor Commented:
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
 
RichWCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now