Avatar of Francisco_M
Francisco_M

asked on 

VB and Ms Access Macro

Hi, I developed a VB app interacting with Ms access 2000. In my database I have some macros that I would like to run from my app... How do I do that? anybody can help?

Francisco.-
Programming

Avatar of undefined
Last Comment
Francisco_M
Avatar of ITBG
ITBG

what kind of app is it?
I think you need to create access object and then just run the macro by name...
Avatar of Francisco_M
Francisco_M

ASKER

Hi ITBG,
all my macros are saved in the accessdatabase.. how do I create access objet in my app to run my macro by name?
Thanks, for your help!

F.
Avatar of ITBG
ITBG

should be something like
Dim appAccess As New Access.Application
but just to run one macro from there it is not the best way to do it
It is mutch better to write vb code insted of using the macro....

Avatar of bsncs02
bsncs02

Hi Franscico,

Try this. It works

    Dim AcApp As Access.Application
    Set AcApp = New Access.Application
    Dim strPath As String
   
    strPath = App.Path

    AcApp.OpenCurrentDatabase strPath & "\<Enter Database Name Here>.mdb"
   
    'If your Access is an adp project then replace the AcApp.OpenCurrentDatabase with this
    'AcApp.OpenAccessProject strPath & "\<Enter Access Project Name Here>.adp"
    AcApp.Visible = False
   
    AcApp.DoCmd.RunMacro "<Enter MacroName Here>"
    AcApp.DoCmd.Maximize
   
    'don't forget to dispose of the object when you close the form you are calling from, _
    'otherwise repeated calls will end up with loads of instances of MSAccess running on your PC
   
    AcApp.Quit
    Set AcApp = Nothing
ASKER CERTIFIED SOLUTION
Avatar of bsncs02
bsncs02

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Francisco_M
Francisco_M

ASKER

Hi bsncs02,
I used the reference to ms access 9.0 library in myb project  and it works fine with your codes. But when I run the same application on a PC that does not have Ms access installed, it gives me an error # 429 "ActiveX component can't create object..." . What can I do to by-pass this?
Thanks a million for your help...

F.
Avatar of Francisco_M
Francisco_M

ASKER

any body can help regarding this issue?
I wii really appreciate...
F.
Programming
Programming

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo