We help IT Professionals succeed at work.

access 2007 macro conditional expression error

kperelman asked
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?
Watch Question

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.



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.


Unlock this solution and get a sample of our free trial.
(No credit card required)


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


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.