dcsimg
Results 1 to 4 of 4

Thread: Noob question: How to tell where functions are being called from

  1. #1

    Thread Starter
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,248

    Question Noob question: How to tell where functions are being called from


    I have lots of experience with VB (mostly with .net), but none to speak of with VBA in Access. I've inherited an Access application and it looks like some of the functions in the modules are not being called from anywhere - at least not any code that I can find. But I'm wondering... is there another way to call a function in an Access application other than through code? i.e. do you specify a function as a property of a button so it knows what to do when clicked ... or some such business as that?

    It's hard for me to trace the flow through the code in this app - I don't see an entry point like sub main()
    I always add to the reputation of those whose post are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,658

    Re: Noob question: How to tell where functions are being called from

    There is no single entry point, any non-Private routine can be executed.

    As to your suspicion about code being called due to properties etc, that is correct - it is possible to call them from a wide variety of places, such as the properties of a field (you can check in the design view of a table, click on each field name to see its properties), and for functions they can even be used within SQL statements... including ones run by external programs using the database.

    Unfortunately I'm not aware of an easy way to find the usages. I suspect there are addins available that can find out, otherwise it will just be matter of looking thru everything manually.

  3. #3

    Thread Starter
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,248

    Re: Noob question: How to tell where functions are being called from

    NOT what I wanted to hear - ugghh! But... thank you very much. At least now I know what I'm up against.
    I always add to the reputation of those whose post are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,014

    Re: Noob question: How to tell where functions are being called from

    check out application.caller


    from help
    Caller Property


    Returns information about how Visual Basic was called (for more information, see the Remarks section).

    Syntax

    expression.Caller(Index)

    expression Required. An expression that returns an Application object.

    Index Optional Variant. An index to the array. This argument is used only when the property returns an array (for more information, see the Remarks section).

    Remarks

    This property returns information about how Visual Basic was called, as shown in the following table.

    Caller Return value
    A custom function entered in a single cell A Range object specifying that cell
    A custom function that is part of an array formula in a range of cells A Range object specifying that range of cells
    An Auto_Open, Auto_Close, Auto_Activate, or Auto_Deactivate macro The name of the document as text
    A macro set by either the OnDoubleClick or OnEntry property The name of the chart object identifier or cell reference (if applicable) to which the macro applies
    The Macro dialog box (Tools menu), or any caller not described above The #REF! error value
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width