LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to call Access's function in different module in Excel VBA

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

 
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
call Module from MS Excel Object - Probably very easy VB questions Kevin Excel Discussion (Misc queries) 4 January 4th 08 02:32 AM
macro in excel to call a access module to run. [email protected] Excel Discussion (Misc queries) 0 April 23rd 07 08:59 PM
to call procedure in a worksheet in a module CAPTGNVR Excel Discussion (Misc queries) 4 January 30th 07 09:39 PM
how to call Access function&module in Excel VBA?? miao jie Excel Programming 1 July 24th 04 04:49 PM
Call Private Function from ThisWorkbook module Beto[_3_] Excel Programming 3 February 25th 04 01:36 PM


All times are GMT +1. The time now is 10:26 AM.

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

About Us

"It's about Microsoft Excel"