access 2007 macro conditional expression error

Posted on 2007-10-02
Last Modified: 2013-11-27
I have a MS Access 2003 application that I want to open (unconverted from access2003) using Access 2007.  

A problem occurs when my macro hits the line where there is a conditional expression command()="" .. I get the message 'the expression you entered has a function name <appl> cant find'?  It does not like the reference to command() but the command() works if I use it in a VBA module.  Also, if I remove the conditional expression the macro runs fine.  The macro runs fine under access 2000, 2002 and 2003.  

What is the problem Access2007 is having and how do I solve it?
Question by:kperelman
    LVL 58

    Expert Comment

    I don't have Access 2007 here, but I believe that the Command() function is not available in so-called "sandbox mode". Some functions are no longer available for the JetEngine and for macros. I'm guessing that is your problem.

    I see two workarounds:

    1) Get rid of the macro and use VB instead. For a start, you can copy-paste your macro as a module; this will convert your macro to simple VB code.

    2) Create a wrapper function in a global module:

    Public Function CommandLine() As String
        CommandLine = Command()
    End Function

    And use that instead in your macro.


    Author Comment

    Thanks for the quick reply ..

    I was hoping for a more definitive documented explanation .. ie: something that specifically says the command() function in macros is no longer supported as well as these other features .. I have not found such info in my searching.  Access2007 implies the access2003 application should work unconverted so is the command() not supported or did I find a bug .. I have encountered similar undocumented macro 'bugs' in the past?  

    Also documentation about this .. and other such changes/info .. would allow me to be pre-emptive and prepare/know what I need to change in my application before I encountered the issue(s).

    Any further info would be appreciated.


    LVL 58

    Accepted Solution

    From a search on "sandbox mode command function" on

    Functions and properties in Access 2007 blocked by sandbox mode

    Enable or disable sandbox mode

    It's not so much that these functions are no longer supported; they are merely blocked by default.

    Good luck!

    Author Comment

    Thanks for the info .. that's what I was looking for.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now