Results 1 to 9 of 9

Thread: Call module

  1. #1
    Join Date
    Apr 2005
    Posts
    39

    Unanswered: Call module

    Hi, I have I think a very straight foreward question. Can I call in a module a procedure which resitst in another database, and if so, what is the code?

    Thanks Felix

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    There are one or two methods I believe. Setting a reference (you will have to browse to the file as it is not stored in the registry) and then refering to it using the syntax ProjectName.ModuleName.ProcName is one.

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I have a database that is nothing but code/modules. I put common functions in it and then add a reference to the database. Which, I think, is what Pootle Flump is getting at. However, I have never referred to the procedure with the syntax, ProjectName.ModuleName.ProcName. As long as your procedure names are not the same, then you can use just the procedure name. I suppose ProjectName.ModuleName.ProcName is more precise, but... for me it is less readable.

    One thing that is problematic with this setup is, if you open Db A and it has a reference to Db B, and then you try to open Db B separately, 9 times out of 10 both databases will blow up and close. It's not a problem that my users ever encounter, but it is kind of annoying.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by DCKunkle
    However, I have never referred to the procedure with the syntax, ProjectName.ModuleName.ProcName. As long as your procedure names are not the same, then you can use just the procedure name. I suppose ProjectName.ModuleName.ProcName is more precise, but... for me it is less readable.
    Yeah - it is optional. I put it in so that it is explicit what is going on. If there are multiple procs of the same name then it is like using DAO.Recordset and ADODB.Recordset to distinguish. If there aren't then you are typing the equivelent of VBA.Left$ - a tad over the top in most peoples books - although I have read an article that recommended it believe it or not.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Mar 2005
    Posts
    261
    If there aren't then you are typing the equivelent of VBA.Left$
    Nearly... the fully qualified version would be VBA.Strings.Left$ (VBA being the Project/Library, Strings being the module within the library and Left$ being the function in the module).

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by waynephillips
    Nearly... the fully qualified version would be VBA.Strings.Left$ (VBA being the Project/Library, Strings being the module within the library and Left$ being the function in the module).
    Lol - always ready with that extra bit of information.

    Wayne - the article I referred to stated that fully qualified names (library.module.function) are more efficient. I imagine it is a fairly moot point (I would guess that it is so but that the gains would be barely measurable) but - is this true? and if so, does it only apply to uncompiled code or would compiled code benefit too?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Mar 2005
    Posts
    261
    Lol - always ready with that extra bit of information.
    I can't help myself sometimes lol

    Wayne - the article I referred to stated that fully qualified names (library.module.function) are more efficient. I imagine it is a fairly moot point (I would guess that it is so but that the gains would be barely measurable) but - is this true? and if so, does it only apply to uncompiled code or would compiled code benefit too?
    It would ever so slightly benefit uncompiled code. However, it can produce less efficient compiled code.

    Basically the underlying P-Code has built in OpCodes for common VBA functions like Left/Mid/InStr etc. This means that there are two ways the compiler can use these functions - either through the VBA Library or through the Virtual Machine directly by using the relevant OpCodes. Obviously the OpCodes route is faster as it doesn't require any DLL calls (it goes directly to the VB Virtual Machine). The difference is marginal.

    Calling VBA.Strings.Left() would force the compiled code to go through the VBA DLL, wheras leaving it as just Left() would use the virtual machine, which is faster. We're only talking a couple of processor cycles though.

    Other than a handful of VBA functions though, there would be no difference in the compiled code.
    Last edited by waynephillips; 02-15-06 at 07:38.

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Lol - brilliant thanks Wayne - your depth of knowledge once more enlightens and astounds me. Though I did notice you nip away briefly - double checking your info?

    Quote Originally Posted by waynephillips
    Obviously the OpCodes route is faster
    Pfff - obviously - I think it barely worth stating and I am quite offended that you thought it necessary

    Quote Originally Posted by Wayne
    The difference is marginal.
    I suspect you could almost define marginal using this as an example.

    Tks
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Mar 2005
    Posts
    261
    Quote Originally Posted by pootle flump
    Lol - brilliant thanks Wayne - your depth of knowledge once more enlightens and astounds me. Though I did notice you nip away briefly - double checking your info?
    Lol - actually I had a visitor (...honest!).

    Quote Originally Posted by pootle flump
    Pfff - obviously - I think it barely worth stating and I am quite offended that you thought it necessary
    Sorry, I sometimes forget and think I'm talking to myself :P lol

    Quote Originally Posted by pootle flump
    I suspect you could almost define marginal using this as an example.
    But of course, if you had a massive loop (say a few hours run time) using only standard VBA functions, it might make a difference of... say a second - or maybe even two

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •