Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you call Access app methods via automation

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Lets say I am going to control an Access application through automation and have set a reference to it, etc. and the object is named MyAccess. Further, let's say the Access application has 2 methods, a sub named SubMethod and a function named FuncMethod.

How do I call and retrieve information from the same? Is it something like MyAccess.SubMethod or varValue = MyAccess.FuncMethod.

Sorry, I'm on a tight schedule and don't have much time to try things out so I thought I would ask the collective experts first.

Have a great day and thanks in advance for any help!
 
Hyia SBendBuckeye,

you might try this:

Code:
    Dim l_appAccess As Access.Application
    
    Set l_appAccess = CreateObject("Access.Application")
    l_appAccess.Visible = True
    'Open db as CurrentDB
    l_appAccess.OpenCurrentDatabase ("Y:\Data\Access\Mailmerge.mdb")
    l_appAccess.Run "modTestExportToExcel.WriteQueryResulToNewExcelSheet"
    
    l_appAccess.CloseCurrentDatabase
    Set l_appAccess = Nothing

It opens the db, runs a proc stored on a module, then closes the db

HTH

Cheers
Nikki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top