[AccessD] Pseudo Pointer to a Function

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Wed Jul 1 09:45:43 CDT 2009


Hi A.D.,

I suppose CallByName will not work for standard/general modules'
subs/functions as CallByName is based (I guess) on COM IDispatch interface's
Invoke(...) method (http://en.wikipedia.org/wiki/IDispatch) and IDispatch
interface is implemented in MS Access/VBA only for custom classes' modules,
which are instantiated internally as COM objects.

--
Shamil

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal
Sent: Wednesday, July 01, 2009 5:55 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Pseudo Pointer to a Function

    This refers to my post of 27-Jun-2009, placed below. While response from
William is awaited, it would be nice if other members of this forum could
also kindly conduct a test and confirm whether any success with using
CallByName() function where the called procedure / function is in a general
module.

Best wishes,
A.D. Tejpal
------------

  ----- Original Message ----- 
  From: A.D.Tejpal 
  To: Access Developers discussion and problem solving 
  Sent: Saturday, June 27, 2009 11:07
  Subject: Re: [AccessD] Pseudo Pointer to a Function


  William,

      The test db is in Access 2000 file format running on Access 2003
installation. Converting it to Access 2003 file format does not make any
difference.

      The called function and procedure are public. All the methods (Run,
Eval and CallByName) require that the called function / procedure should be
public (even if located within the module holding the calling code).

      Called function / procedure (public) - located in general module:
      (Error 438)
      ==========================================
      When public function / procedure located in a general module is called
via CallByName function using the following syntax, it attracts error 438:

      CallByName Modules("<<ModuleName>>"),  _
                  "<<CalledProcName>>", VbMethod

      Note - The called procedure is a simple one - merely displaying a
message.
      ==========================================

      Called function / procedure (public) - located in class module:
      (Works OK)
      ==========================================
      All the following statements are found to work smoothly:

      (a) Called proc is in the same form:
      CallByName Me, "<<CalledProcName>>", VbMethod

      (b) Called proc is in another form:
      CallByName Forms("<<FormName>>"),  _
                      "<<CalledProcName>>", VbMethod

      (c) Called proc is in a class:
      CallByName PointerToClassObject,  _
                      "<<CalledProcName>>", VbMethod
      ==========================================

  Best wishes,
  A.D. Tejpal
  ------------

    ----- Original Message ----- 
    From: William Hindman 
    To: Access Developers discussion and problem solving 
    Sent: Saturday, June 27, 2009 02:21
    Subject: Re: [AccessD] Pseudo Pointer to a Function


    A.D.

    ...are you using A2k3? ...is the function public?

    William

    --------------------------------------------------
    From: "A.D.Tejpal" <adtp at airtelmail.in>
    Sent: Thursday, June 25, 2009 5:27 AM
    To: "Access Developers discussion and problem solving" 
    <accessd at databaseadvisors.com>
    Subject: Re: [AccessD] Pseudo Pointer to a Function

    > William,
    >
    >    It appears that the procedure / function called by CallByName() 
    > function has to be in a class module. Could you kindly verify again 
    > whether it works successfully for procedures / functions contained in 
    > general modules ?
    >
    >    I am getting error 438 in such a case.
    >
    > Best wishes,
    > A.D. Tejpal
    > ------------
    >
    >  ----- Original Message ----- 
    >  From: William Hindman
    >  To: Access Developers discussion and problem solving
    >  Sent: Tuesday, June 23, 2009 23:21
    >  Subject: Re: [AccessD] Pseudo Pointer to a Function
    >
    >  Arthur
    >
    >  ...from my treeview menu I use either of the following in a select 
    > statement
    >              'call a function from a module, "strObjectName" is from
my
    >  tblSwitchboard
    >              CallByName modules("mdlMenuFunctions"), strObjectName, 
    > VbMethod
    >
    >              'call a sub from the switchboard form module itself
    >              CallByName CodeContextObject, strObjectName, VbMethod,
    >  strObjectAddtnl
    >
    >  ...hth
    >  William
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4204 (20090701) __________

The message was checked by ESET NOD32 Antivirus.

http://www.esetnod32.ru






More information about the AccessD mailing list