Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    NSW, Australia
    Thanked 0 Times in 0 Posts

    Library procedure running calling dbs procedure (Access 97)

    We have developed mde database with various common functions to use as our library. All our databases set up a reference to this library and call up required functions when required. This works fine in most cases, however, sometimes (really but nevertheless) we want to add the ability to our library to call functions stored in the database referencing the library. The question is, how do you force a function in the running mdb database to be executed from code in the mde library database referenced by the running database. I hope that makes sense.

    For example:

    There are two database, MyDbs.mdb and MyLib.mde.

    MyDbs.mdb normal database has a reference link to MyLib.mde library database.

    Both databases have a function called FormatMyReport. In addition MyLib database has a function called CreateDefaultReport.

    All databases using the library use CreateDefaultReport function to generate default organisation reports by passing required table/query name and sort/group field names. CreateDefaultReport function generates custom reports and calls FormatMyReport function to apply specific formatting and graphics. This works great most of the time.

    However, sometime the programmer may need to format a report differently than the default. The programmer would still want to use CreateDefaultReport function to create the report but than wants to divert CreateDefaultReport to call FormatMyReport function in his personal database - not the one in the library. We have set up the library to accept optional UseCustomFormatting as a parameter and would like to use that parameter to either divert the call from the library function called CreateDefaultReport to another library function called FormatMyReport or a custom function called FormatMyReport located in the database that's calling the library.

    We are currently unsure how to do it.

    Anyone ideas?

    Any comments will be appreciated.

    Thank you. <img src=/S/hiding.gif border=0 alt=hiding width=70 height=24>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Library procedure running calling dbs procedure (Access 97)

    I haven't tried this in a complex situation, but it might help. In a library database, when you call a function FName(args), Access looks for the function FName in the library database. However, when you call Eval("FName(args)"), Access seems to look for the function FName in the calling database.

    So in your situation:

    If UseCustomFormatting = True Then
    retVal = Eval("FormatMyReport(ArgumentsIfAny)")
    retVal = FormatMyReport(ArgumentsIfAny)
    End If

    You'll have to be careful about passing arguments with quotes.


  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Library procedure running calling dbs procedure (Access 97)

    I would suggest you rethink the idea. A library database allows you to include code in your current database without having to embed it in the database. If you make the library call routines in the current database or specifically reference objects in the current db, you have violated the library concept since the library now becomes dependent on finding the routines/objects it calls in the current db.

    You would be better advised to handle the alternate formatting with code called from the library. You can always pass in objects from the current db for it to act on.

Posting Permissions

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