Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ms access - matlab link

Subject: ms access - matlab link

From: Rogelio

Date: 13 May, 2012 11:43:07

Message: 1 of 5

Hi there!

Im stuck in this problem and I dont find any helpful information out there. I have a function in vba ms access that I want to call from matlab. Actually, my goal is to use that function in fmincon and optimize it. But first Im just trying to call it.

So far I have this:
Access = actxserver('Access.application');
Db = invoke(Access.DBEngine,'OpenDatabase', 'path.accdb');

The question is how to call my function in accesss? something like:
result = Access.Run('myaccessfun',param);

Any help is appreciated!

Subject: ms access - matlab link

From: Rogelio

Date: 13 May, 2012 19:13:07

Message: 2 of 5

"Rogelio " <rogelioa.deletethis@math.uio.no> wrote in message <joo6ob$hje$1@newscl01ah.mathworks.com>...
> Hi there!
>
> Im stuck in this problem and I dont find any helpful information out there. I have a function in vba ms access that I want to call from matlab. Actually, my goal is to use that function in fmincon and optimize it. But first Im just trying to call it.
>
> So far I have this:
> Access = actxserver('Access.application');
> Db = invoke(Access.DBEngine,'OpenDatabase', 'path.accdb');
>
> The question is how to call my function in accesss? something like:
> result = Access.Run('myaccessfun',param);
>
> Any help is appreciated!

I have some small achievements. The proper method to call on the COM object is 'Run' (just as calling myaccessfun from an other database in access). If I write Access.methodsview in matlab, I can see all the methods supported, and fortunately 'Run' is there. To double check I can write :
e = Access.Application
e.ismethod('Run')
and the answer is 1, meaning that 'Run' is a method of my access.application.
So it is only matter to pass the 'Run' method correctly. This is the part that I am missing!. I have tried this options with no success
xx=invoke(Access.Application,'Run','myaccessfun',3)
xx=invoke(Access.Application.Run,'myaccessfun',3)

I can also open the database using this notation (which is consistent with the methods supported by Access.Appliaction) :
Access.Application.OpenCurrentDatabase('path.mdb')

Any idea?

Subject: ms access - matlab link

From: Steven_Lord

Date: 14 May, 2012 13:51:10

Message: 3 of 5



"Rogelio " <rogelioa.deletethis@math.uio.no> wrote in message
news:jop143$rim$1@newscl01ah.mathworks.com...
> "Rogelio " <rogelioa.deletethis@math.uio.no> wrote in message
> <joo6ob$hje$1@newscl01ah.mathworks.com>...
>> Hi there!
>>
>> Im stuck in this problem and I dont find any helpful information out
>> there. I have a function in vba ms access that I want to call from
>> matlab. Actually, my goal is to use that function in fmincon and optimize
>> it. But first Im just trying to call it.
>>
>> So far I have this:
>> Access = actxserver('Access.application');
>> Db = invoke(Access.DBEngine,'OpenDatabase', 'path.accdb'); The question
>> is how to call my function in accesss? something like:
>> result = Access.Run('myaccessfun',param);
>>
>> Any help is appreciated!
>
> I have some small achievements. The proper method to call on the COM
> object is 'Run' (just as calling myaccessfun from an other database in
> access). If I write Access.methodsview in matlab, I can see all the
> methods supported, and fortunately 'Run' is there. To double check I can
> write :
> e = Access.Application
> e.ismethod('Run')
> and the answer is 1, meaning that 'Run' is a method of my
> access.application.
> So it is only matter to pass the 'Run' method correctly. This is the part
> that I am missing!. I have tried this options with no success
> xx=invoke(Access.Application,'Run','myaccessfun',3)
> xx=invoke(Access.Application.Run,'myaccessfun',3)
> I can also open the database using this notation (which is consistent with
> the methods supported by Access.Appliaction) :
> Access.Application.OpenCurrentDatabase('path.mdb')
> Any idea?

The reference for the Access.Application object is located on Microsoft's
website:

http://msdn.microsoft.com/en-us/library/ff841371

If your myaccessfun function accepts a numeric input, I _think_ what you
wrote above should work; if it accepts something else, you will need to
modify the command to pass the appropriate input to myaccessfun.

Since you said you've tried this with no success, what happened when you
tried it? Did MATLAB or Microsoft Access throw an error? A warning? Did it
give you the wrong answer?

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: ms access - matlab link

From: Rogelio

Date: 14 May, 2012 17:12:07

Message: 4 of 5

"Steven_Lord" <slord@mathworks.com> wrote in message <jor2ke$bt9$1@newscl01ah.mathworks.com>...
>
>
> "Rogelio " <rogelioa.deletethis@math.uio.no> wrote in message
> news:jop143$rim$1@newscl01ah.mathworks.com...
> > "Rogelio " <rogelioa.deletethis@math.uio.no> wrote in message
> > <joo6ob$hje$1@newscl01ah.mathworks.com>...
> >> Hi there!
> >>
> >> Im stuck in this problem and I dont find any helpful information out
> >> there. I have a function in vba ms access that I want to call from
> >> matlab. Actually, my goal is to use that function in fmincon and optimize
> >> it. But first Im just trying to call it.
> >>
> >> So far I have this:
> >> Access = actxserver('Access.application');
> >> Db = invoke(Access.DBEngine,'OpenDatabase', 'path.accdb'); The question
> >> is how to call my function in accesss? something like:
> >> result = Access.Run('myaccessfun',param);
> >>
> >> Any help is appreciated!
> >
> > I have some small achievements. The proper method to call on the COM
> > object is 'Run' (just as calling myaccessfun from an other database in
> > access). If I write Access.methodsview in matlab, I can see all the
> > methods supported, and fortunately 'Run' is there. To double check I can
> > write :
> > e = Access.Application
> > e.ismethod('Run')
> > and the answer is 1, meaning that 'Run' is a method of my
> > access.application.
> > So it is only matter to pass the 'Run' method correctly. This is the part
> > that I am missing!. I have tried this options with no success
> > xx=invoke(Access.Application,'Run','myaccessfun',3)
> > xx=invoke(Access.Application.Run,'myaccessfun',3)
> > I can also open the database using this notation (which is consistent with
> > the methods supported by Access.Appliaction) :
> > Access.Application.OpenCurrentDatabase('path.mdb')
> > Any idea?
>
> The reference for the Access.Application object is located on Microsoft's
> website:
>
> http://msdn.microsoft.com/en-us/library/ff841371
>
> If your myaccessfun function accepts a numeric input, I _think_ what you
> wrote above should work; if it accepts something else, you will need to
> modify the command to pass the appropriate input to myaccessfun.
>
> Since you said you've tried this with no success, what happened when you
> tried it? Did MATLAB or Microsoft Access throw an error? A warning? Did it
> give you the wrong answer?
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Hi Steve,

Matlab throws the following error:

??? No method 'Run' with matching signature found for class
'Interface.Microsoft_Access_12.0_Object_Library._Application'.

And yes, myaccessfun accepts a numeric value. Actually it is myaccessfun(a) = 5 * a just to learn how to call functions.
 

Subject: ms access - matlab link

From: Ian

Date: 26 Nov, 2013 14:12:09

Message: 5 of 5

Hi,
I'm aware this topic is over a year old.
I'm having the same issue. Were you ever able to solve this?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us