By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Passing VBA class module instance BYREF to .NET DLL, MS ACCESS refuses to close

P: 1
Hi,

Need some help.. I have a VBA class module in MS ACCESS. In the same MS ACCESS app, I am calling a .NET DLL (which i have exposed as COM-visible) and passing BYREF an instance of the VBA class module as an argument to one of the .NET DLL method. Step by step, here's what i am doing:

1. Create vba class module in MS ACCESS
Option Compare Database
Option Explicit
...
Public Function DoSomething(ByVal S as String, ByRef RetVal as Double) As Long
RetVal = 100
DoSomething = 0
End Function

2. Create a .NET DLL and expose it as COM
Public Class COMClass
Public Function UseVBAClassAndDoSomething(ByVal S as String, ByRef VBAClass as Object, ByRef RetVal as double) as Integer
Dim R as Double
VBAClass.DoSomething("anything", R)
RetVal = R + 10
UseVBAClassAndDoSomething = 0
End Function
End Class

3. From MS ACCESS, CreateObject .NET DLL and pass a reference of the above class (say call it Class1) to a method in the .NET DLL

Dim C as Class1
Dim R as Double
Dim O as Object
Set C = New Class1
Set O = CreateObject("MyNETDLL.COMClass")
Msgbox O.UseVBAClassAndDoSomething("just a string", C, R)
Set O = Nothing
Set C = Nothing

It works as intended but when the MS ACCESS app closes, MS ACCESS process is still runnning and you cannot close MS ACCESS.exe (unless you goto Taskbar and kill the process).

Has anyone experienced the same? How did you resolve this? Thanks in advance
Apr 10 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.