On 30 Sep 2004 03:08:40 -0700,
fi*@ifs.inchcape.co.uk (Tim ffitch)
wrote:
Hi
I have created a VB dll file that contains common functions I use
across various projects in VB, Access and Excel. Rather than have to
code the functions in each I decided to use the dll route.
The problem being that I can't call these functions from the query
designer in Access. I decided that I would try the route of declaring
the functions from the dll file the same way you would for the Windows
API. Access then complains that it cant't find a valid access point in
the dll file and then gives the name of the function I am calling.
Has anyone got any ideas how I acn get this to work?
Many thanks
Tim ffitch
Hi
here is something I copied from Google (naughty but the url is just
too complicated) which spells things out a bit. To use in a query I
guess you would have to write a wrapper function (or can SQL contain
method calls - I've never tried)
David
Search Result 2
From: Greg Ellison [MS] (gr***@online.microsoft.com)
Subject: RE: Calling proceedure in external DLL
View: Complete Thread (3 articles)
Original Format
Newsgroups: microsoft.public.office.developer.vba
Date: 2002-06-17 08:48:27 PST
Hello Michael,
Any dll that you create in Visual Basic 6.0 is a COM (e.g. ActiveX)
dll.
When you create the ActiveX dll project in VB, you were provided by
default
a Class module. By default it is Class1. You need to put your
procedures in
that class module in order to call them from your template. Also, what
was
the name of the Project via the Project | Properties menu in VB6?
Both the
Project name, and the name of the class module, are important because
together they make up the ProgID. Suppose I create a VB6 ActiveX DLL
project and I change the Project name to: MyCoolProject. Then, I
changed
the name of the Class1 module to : MyCoolClass. Suppose I have a
Public
method of the class as follows:
Public MyCoolMethod (ByVal arg1 as String, ByVal arg2 as Long)
'my code for MyCoolMethod
End Sub
Now from VBA, I use Tools | References to reference the MyCoolProject
dll.
Here is how you can call the MyCoolMethod from VBA:
Dim oCool as MyCoolProject.MyCoolClass
Set oCool = New MyCoolProject.MyCoolClass
oCool.MyCoolMethod "some string", 1
Set oCool = Nothing 'release the object from memory
You can move the 'Dim oCool' statement to the module level if you want
to
use it multiple times. Then, move the 'Set oCool' to the open event of
the
document (or some other place so it is called only once).
There is an alternative for the above you can explore: When designing
your
class module in VB6 for your ActiveX dll, you will see a property of
the
Class module called 'Instancing' that you can set to 'GlobalMultiUse'
to
allow you to call the methods in the class without having to
instantiate
the object using the New keyword. See the Instancing property in VB6
online help for more information.
Best regards,
Greg Ellison
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no
rights.