473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Call VB Functions from Query Design Grid

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
Nov 13 '05 #1
7 5866
On 30 Sep 2004 03:08:40 -0700, fi*@ifs.inchcape.co.uk (Tim ffitch)
wrote:

You may be confused about the two kinds of DLLs there are:
1: Classic DLLs, including Windows API and DLLs written typically in C
or C++. They can be called like you indicated. These CANNOT be written
using VB.
2: ActiveX DLLs: the opposite of (1). Are registered using
regsvr32.exe, and can then be instantiated (CreateObject) and its
methods called (myobject.mymethod).

-Tom.

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


Nov 13 '05 #2
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.
Nov 13 '05 #3
.... use Power Basic or True Basic instead of VB. Both have
a high level of compatibility with VB, but without the
artificial restrictions...

"Tim ffitch" <fi*@ifs.inchcape.co.uk> wrote in message
news:13**************************@posting.google.c om...
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

Nov 13 '05 #4
Hi

I would like to thank you all for your responses so far. However
nothing so far is going to help.

I had already set the instancing of the class to GlobalMultiUse.

In my original attempt to get this working I had set a reference to my
dll and then created a public variable of my class type. I can then
succesfully call my functions from within a code module in Access.
However if I include the functions in a query I get an error stating
that my function is not defined. It seems to me that the queries
cannot refer to user defined libraries.

This is why I then tried to use the Declare statement as you would do
with API functions. I removed the reference to my dll before trying
this as I thought the two methods might clash. What seems strange
though is that if the functions were written in another Access file
and I set a reference to that file then the functions would work.

However I have spotted one common theme. If you add a class module to
access you cannot use the class or its methods in a query either.

Any other ideas anybody?

Many thanks
Tim ffitch

fi*@ifs.inchcape.co.uk (Tim ffitch) wrote in message news:<13**************************@posting.google. com>...
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

Nov 13 '05 #5
On 1 Oct 2004 04:02:29 -0700, fi*@ifs.inchcape.co.uk (Tim ffitch)
wrote:
Hi

I would like to thank you all for your responses so far. However
nothing so far is going to help.

I had already set the instancing of the class to GlobalMultiUse.

In my original attempt to get this working I had set a reference to my
dll and then created a public variable of my class type. I can then
succesfully call my functions from within a code module in Access.
However if I include the functions in a query I get an error stating
that my function is not defined. It seems to me that the queries
cannot refer to user defined libraries.

This is why I then tried to use the Declare statement as you would do
with API functions. I removed the reference to my dll before trying
this as I thought the two methods might clash. What seems strange
though is that if the functions were written in another Access file
and I set a reference to that file then the functions would work.

However I have spotted one common theme. If you add a class module to
access you cannot use the class or its methods in a query either.

Any other ideas anybody?

Many thanks
Tim ffitch


Hi
other ideas all a fair amount of work:
1. Write your DLL in C
2. Use #include to put the text of your code into each of your
applications. (Ask Microsoft how to do this)
3. Simulate 2 by using insertlines on a module.
-David

Nov 13 '05 #6
SQL can't call functions from classes. You can only call functions
from standard modules. You may wish to write wrapper functions in
your standard modules which call your class functions.

Active X DLL's don't have function entry points like Win DLL's.
Instead, they have a standard entry point which is used to evaluate
functions. Windows calls the standard entry point and requests
the function result. Nobody, not even C++ programmers, does OLE
programming directly: it is always handled by library functions.

(david)

"Tim ffitch" <fi*@ifs.inchcape.co.uk> wrote in message
news:13**************************@posting.google.c om...
Hi

I would like to thank you all for your responses so far. However
nothing so far is going to help.

I had already set the instancing of the class to GlobalMultiUse.

In my original attempt to get this working I had set a reference to my
dll and then created a public variable of my class type. I can then
succesfully call my functions from within a code module in Access.
However if I include the functions in a query I get an error stating
that my function is not defined. It seems to me that the queries
cannot refer to user defined libraries.

This is why I then tried to use the Declare statement as you would do
with API functions. I removed the reference to my dll before trying
this as I thought the two methods might clash. What seems strange
though is that if the functions were written in another Access file
and I set a reference to that file then the functions would work.

However I have spotted one common theme. If you add a class module to
access you cannot use the class or its methods in a query either.

Any other ideas anybody?

Many thanks
Tim ffitch

fi*@ifs.inchcape.co.uk (Tim ffitch) wrote in message

news:<13**************************@posting.google. com>...
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

Nov 13 '05 #7
Hi

Thanks for your detailed reply.

I had already thought of writting wrapper functions. It seems either
this or writting a C++ win32.dll are the only answers.

I would like to go down the C++ route, but I have no experience. So
unless I can get some guidance on this, wrapper functions are my only
option.

Kind regards
Tim ffitch
"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message news:<41**********************@news.syd.swiftdsl.c om.au>...
SQL can't call functions from classes. You can only call functions
from standard modules. You may wish to write wrapper functions in
your standard modules which call your class functions.

Active X DLL's don't have function entry points like Win DLL's.
Instead, they have a standard entry point which is used to evaluate
functions. Windows calls the standard entry point and requests
the function result. Nobody, not even C++ programmers, does OLE
programming directly: it is always handled by library functions.

(david)

"Tim ffitch" <fi*@ifs.inchcape.co.uk> wrote in message
news:13**************************@posting.google.c om...
Hi

I would like to thank you all for your responses so far. However
nothing so far is going to help.

I had already set the instancing of the class to GlobalMultiUse.

In my original attempt to get this working I had set a reference to my
dll and then created a public variable of my class type. I can then
succesfully call my functions from within a code module in Access.
However if I include the functions in a query I get an error stating
that my function is not defined. It seems to me that the queries
cannot refer to user defined libraries.

This is why I then tried to use the Declare statement as you would do
with API functions. I removed the reference to my dll before trying
this as I thought the two methods might clash. What seems strange
though is that if the functions were written in another Access file
and I set a reference to that file then the functions would work.

However I have spotted one common theme. If you add a class module to
access you cannot use the class or its methods in a query either.

Any other ideas anybody?

Many thanks
Tim ffitch

fi*@ifs.inchcape.co.uk (Tim ffitch) wrote in message

news:<13**************************@posting.google. com>...
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

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg Chapman | last post by:
I am at my wit's end trying to get information out of Streamline.net's support dept about my problem. They reply quickly enough, but seem to try and give out the least possible amount of info each...
6
by: NB | last post by:
Hi Is there any way to call up the query design view from code? In my compiled-as-MDE app everything is hidden from end users. However, I want advanced user to have access to the query design...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
1
by: Robert | last post by:
I am trying to create a db for service providers by county. I'm relatively new to db programming, but I have done quite a bit of programming ranging from the old basic days up to doing some...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
4
by: amy | last post by:
Hi to Everyone: I need big help on how to query the Age range. Age field is text data type, Age are from 0 wk, 1 wk, 2wk.....up to 15 wk. Try to set up query in Query desing mode with criteria is...
1
by: tom.youdan | last post by:
Hi, I have an access dbs with 2 key tables. One is a State table that has State id and State name fields. This feeds a combo box in a form to provide a reference point for the State Id field in...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.