Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default running Access procedure from Excel

Hello,

I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub

Thanks in advance!

Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default running Access procedure from Excel

is "getdata_Kenya" the name of a query in your database? A module
name? A sub procedure name? If it's a query, you could use:
appAcc.DoCmd.OpenQuery "getdata_Kenya"

If a function, try this:
appAcc.DoCmd.OpenFunction "getdata_Kenya"
savalou wrote:
Hello,

I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub

Thanks in advance!

Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default running Access procedure from Excel

On Sep 14, 2:16 pm, JW wrote:
is "getdata_Kenya" the name of a query in your database? A module
name? A sub procedure name? If it's a query, you could use:
appAcc.DoCmd.OpenQuery "getdata_Kenya"

If a function, try this:
appAcc.DoCmd.OpenFunction "getdata_Kenya"



savalou wrote:
Hello,


I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub


Thanks in advance!


Dave- Hide quoted text -


- Show quoted text -


It's a sub procedure.

Thanks,

Dave

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default running Access procedure from Excel

Works for me. Could this be a security issue where you need to enable macros
to be run? In Access 2003 I specifically have to click "Open" in a dialog
because it has code in it.

"savalou" wrote in message
oups.com...
Hello,

I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub

Thanks in advance!

Dave



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default running Access procedure from Excel

On Sep 14, 3:24 pm, <- wrote:
Works for me. Could this be a security issue where you need to enable macros
to be run? In Access 2003 I specifically have to click "Open" in a dialog
because it has code in it.

"savalou" wrote in message

oups.com...



Hello,


I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub


Thanks in advance!


Dave- Hide quoted text -


- Show quoted text -


I have the macros enabled. This is working for me now. I was getting
an error message, but it was actually peforming the sub routine, so I
put an 'On error resume next' before the appAcc.Run "getdata_Kenya" .
Still don't know what the error is all about.

thanks again for your time.

Dave





  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default running Access procedure from Excel

Looks like there's something in "getdata_Kenya" that's erroring out.
Possibly the error doesn't happen when you run it from Access, but just from
Excel?


"savalou" wrote in message
oups.com...
On Sep 14, 3:24 pm, <- wrote:
Works for me. Could this be a security issue where you need to enable
macros
to be run? In Access 2003 I specifically have to click "Open" in a dialog
because it has code in it.

"savalou" wrote in message

oups.com...



Hello,


I'm trying to run a procedure in access using excel VBA. I set the
access object library reference and ran this code but it hangs on the
appAcc.run command; Run-time error '440': Method 'Run' of object
'_Application' failed.


Sub GetKenyaAPRdata()
Dim appAcc As Access.Application
Set appAcc = New Access.Application
appAcc.Visible = False
appAcc.OpenCurrentDatabase ("C:\PMS\PEPFARresults.mdb")
appAcc.Run "getdata_Kenya"
appAcc.Quit
Set appAcc = Nothing
End Sub


Thanks in advance!


Dave- Hide quoted text -


- Show quoted text -


I have the macros enabled. This is working for me now. I was getting
an error message, but it was actually peforming the sub routine, so I
put an 'On error resume next' before the appAcc.Run "getdata_Kenya" .
Still don't know what the error is all about.

thanks again for your time.

Dave





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Ontime's procedure while another function is running? Enter The Excel Programming 1 May 11th 07 05:58 AM
Opening an Access Database and running procedure Via Excel VBA Paul Faulkner Excel Programming 0 June 7th 06 02:17 PM
Run a MS Access Procedure from Excel Mark Excel Programming 4 August 10th 05 01:25 PM
Getting Access Error Messages when running Access through Excel Dkline[_2_] Excel Programming 0 October 12th 04 09:35 PM
Running Event Procedure When Cell Updated on Excel Worksheet Tom Ogilvy Excel Programming 0 August 19th 04 03:38 PM


All times are GMT +1. The time now is 08:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"