473,729 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5903
On 30 Sep 2004 03:08:40 -0700, fi*@ifs.inchcap e.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.mymet hod).

-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.inchcap e.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.m icrosoft.com)
Subject: RE: Calling proceedure in external DLL
View: Complete Thread (3 articles)
Original Format
Newsgroups: microsoft.publi c.office.develo per.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.M yCoolClass
Set oCool = New MyCoolProject.M yCoolClass
oCool.MyCoolMet hod "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.inchca pe.co.uk> wrote in message
news:13******** *************** ***@posting.goo gle.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 #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.inchcap e.co.uk (Tim ffitch) wrote in message news:<13******* *************** ****@posting.go ogle.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.inchcap e.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.inchca pe.co.uk> wrote in message
news:13******** *************** ***@posting.goo gle.com...
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.inchcap e.co.uk (Tim ffitch) wrote in message

news:<13******* *************** ****@posting.go ogle.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@epsomdot comdotau> wrote in message news:<41******* *************** @news.syd.swift dsl.com.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.inchca pe.co.uk> wrote in message
news:13******** *************** ***@posting.goo gle.com...
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.inchcap e.co.uk (Tim ffitch) wrote in message

news:<13******* *************** ****@posting.go ogle.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
5289
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 time. The transcript so far is reproduced for your amusement below. To summarise: I've put up a Sudoku-solving program called Sudoku.exe. I want to call it in a php script to solve a puzzle and output the solution. It works fine with...
6
13297
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 view so they can create, run and export their own query. Another question is: can they be prevented from saving those on-the-fly queries?
6
29940
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 newsgroups, the access support centre, I can seem to find no similar situation. I am not using any references, or VBA at all in the first place. I am trying to set up a simple (or so I thought) query to work with the text of two tables. ...
1
3255
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 programming in the HotDocs software. I've kind of accomplished my goal in access, but I'm not quite there yet and figure I've really screwed something up. The db consists of 5 tables I believe. T1 is the main contact info, with an autonumber ID...
7
6882
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 expression should return the 4 leftmost characters of the FilmNo
4
7167
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 0-4wk, i put in this: "0 wk" Or "1 wk" Or "2 wk" Or "3 wk" Or "4 wk". The query result includes ages between1-4wk but also10-15 wk. Even I change the Age field to number data type, still the same problem. I am not a access programmer but just...
1
1421
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 the Main table. This allows multiple State instances, as I am mapping a number of organizations in each state. The main table has one entry per organization and one state reference per line. It also has 7 Yes/No fields to identify what...
22
31207
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 June, and will return all records in that month.
8
36135
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 button on it. If the query returns multiple results, a new window is opened with a grid containing the results. When the user double clicks on the desired row in the grid, I want the first form to populate with the correct data. I don't know how...
0
9293
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9221
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9162
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8165
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6028
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4799
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3246
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.