Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a question for how to call Access procedure/Function in different module in Excel
VBA? Now I have Access, And I define a simple subform for test in different sub module: data_pool.mdb.module1 Sub test1() Dim conDatabase As ADODB.Connection Set conDatabase = Application.CurrentProject.Connection Dim SQL As String SQL = "update country set scale = scale + 1 where country = ""dd"" " conDatabase.Execute (SQL) 'conDatabase.CommitTrans 'Call table_conversion End Sub data_pool.mdb.module2 Sub test1() msgbox "ddd" End Sub right now I wanna call the test1() in my Excel file (add Microsoft Access 10 library in reference) myExl.xls Sub Button36_Click() Dim accessObj As Object Dim ac As Access.Application Dim path As String path = ActiveWorkbook.path path = path & "\data_pool.mdb" ' Create instance of Access Application object. Set ac = CreateObject("Access.Application") ' Open WizCode database in Microsoft Access window. ac.OpenCurrentDatabase path, Exclusive:=True ' Exclusive = false means can not open access if it is opened 'ac.Run "module1.test1" ac.Run "test1" 'ac.Run "[module1.test1]" ac.CloseCurrentDatabase ac.Quit End Sub If the different Function name in different module in Access, the code is run well but I set same function name in different module in Access, the Run method can not work. ( In Access, I can set the same function name in different module and run well) anyone can help me out, thanks a lot |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
call Module from MS Excel Object - Probably very easy VB questions | Excel Discussion (Misc queries) | |||
macro in excel to call a access module to run. | Excel Discussion (Misc queries) | |||
to call procedure in a worksheet in a module | Excel Discussion (Misc queries) | |||
how to call Access function&module in Excel VBA?? | Excel Programming | |||
Call Private Function from ThisWorkbook module | Excel Programming |