access 2007 macro conditional expression error

Posted on 2007-10-02
Medium Priority
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
  • 2
  • 2
LVL 58

Expert Comment

ID: 20003390
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

ID: 20013257
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

harfang earned 2000 total points
ID: 20014604
From a search on "sandbox mode command function" on microsoft.com:

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

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


Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 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