Results 1 to 3 of 3
  1. #1
    bubu678 is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    1

    Dynamic functions

    I have functions in a module that I would like to execute by "building" the function name.

    example: In module A I have
    Function AAA (ByVal Arg1, ... ByVal Argn)


    ...
    End Function

    Function BBB (ByVal Arg1, ... ByVal Argn)
    ...
    End Function

    Function CCC (ByVal Arg1, ... ByVal Argn)
    ...
    End Function

    I would like then to run the appropriate one something like this:
    IF case1 THEN
    sFunction = "AAA (arg1, ... argn)"
    else
    sFunction = "BBB (arg1, ... argn)"
    END IF

    EXECUTE sFunction

    Can that be done in Access 2007?

    Thanking everyone in advance...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Untested, but you can try wrapping it in the Eval() function:

    Call Eval(sFunction)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    if eval doesn't work, just call the specific function under each case statement. there's nothing wrong with that either.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Functions
    By Alex Motilal in forum Programming
    Replies: 2
    Last Post: 09-27-2010, 08:06 AM
  2. sum functions
    By trippers in forum Queries
    Replies: 2
    Last Post: 08-04-2010, 07:09 PM
  3. Functions
    By jamin14 in forum Programming
    Replies: 1
    Last Post: 03-25-2010, 08:16 AM
  4. Help with functions / procedures
    By curnil in forum Programming
    Replies: 3
    Last Post: 03-09-2010, 05:41 PM
  5. Multiple IIF functions possible?
    By Northgate in forum Access
    Replies: 0
    Last Post: 10-08-2008, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums