Reputation: 221
Is it possible to call a function in a module in MS Access with VB.net?
I have codes in my laptop using Imports Microsoft.Office.Interop.Access but all objects I declare under .Access is ambiguous, so I want to try other options.
This is for educational and experimental use only.
Upvotes: 1
Views: 2296
Reputation: 13984
Yes, it is possible by using automation: http://support.microsoft.com/default.aspx?scid=kb;en-us;306682
Case "Access"
Dim oAccess As Access.ApplicationClass
'Start Access and open the database.
oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase("c:\db1.mdb", False)
'Run the macros.
oAccess.Run ("DoKbTest")
oAccess.Run("DoKbTestWithParameter", "Hello from VB .NET Client")
'Clean-up: Quit Access without saving changes to the database.
oAccess.DoCmd().Quit (Access.AcQuitOption.acQuitSaveNone)
System.Runtime.InteropServices.Marshal.ReleaseComObject (oAccess)
oAccess = Nothing
Upvotes: 2