Solved

Access VBA Error - Undefined Function 'Left' in Expression

Posted on 2012-04-04
9
2,152 Views
Last Modified: 2012-04-04
Hello,

My Access database has recently had trouble any time I run code, a query or report that calls one of the standard functions (Left(), Right(), Date(), etc.).  I get an error "Undefined Function 'Left'  in Expression"

When I compile my code, I get no compile-time errors.

I know this is frequently associated with broken references, however I have no missing references (see the attached image).

Any thoughts?

Thanks.
References.png
0
Comment
Question by:Orcadian
  • 5
  • 4
9 Comments
 
LVL 75
ID: 37809503
Well, 99% of the time ... Classic case of Missing References.

Is this an A2010 db?  If so, is it in a Trusted Location ?
0
 

Author Comment

by:Orcadian
ID: 37809507
I agree, which is why I checked the references, and you can see that none are missing.  That's when I got stumped.

This is an Access 2007 DB and it is in a Trusted Location.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 37809508
OK ... so it's A2007.  Still, it needs to be in a Trusted Location.  Has the db been moved?

If not, try running the procedure below (ignore the Reference part):


Open the VBA Editor and from the menu ...Tools>>References ....
If you see any listed as **Missing: <reference name>, including the asterisks and the word Missing, the
you need to fix that first.

Then, follow this procedure:

****
0) **Backup your MDB BEFORE running this procedure**
****
1) Compact and Repair the MDB, as follows:
Hold down the Shift key and open the MDB, then from the menu >>Tools>>Database Utilities>>Compact and Repair ...
Close the mdb after the Compact & Repair.
2) Execute the Decompile (See example syntax below) >> after which, your database will reopen.
3) Close the mdb
4) Open the mdb and do a Compact and Repair (#1 above).
5) Close the mdb.
6) Open the mdb:
    a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
    b) From the VBA Editor Menu at the top of the window:
       >>Debug>>Compile
        Note ... after the word Compile ...you will see the name of your 'Project' - just an fyi.

7) Close the mdb
8) Compact and Repair one more time.

*** Executing the DeCompile **EXAMPLE**:
Here is an **example** of the command line syntax  (be SURE to adjust your path and file name accordingly) before executing the decompile:

Run this from Start>>Run, enter the following command line - **all on one line** - it may appear like two lines here in the post:
Also, the double quotes are required.

"C:\Program Files\Microsoft Office\Office\Msaccess.exe" /decompile "C:\Access2003Clients\YourMdbNameHERE.mdb"

For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:

http://www.trigeminal.com/usenet/usenet004.asp?1033

AND ...
Once you get familiar with the Decompile idea (and ALWAYS make a BACKUP first!) ... you can add both Decompile and Compact/Repair to the Right Click menus in Windows Explorer, which I use multiple times daily:

Getting the Decompile and Compact context menu options
http://access.mvps.org/access/modules/mdl0039.htm

mx
0
 

Author Closing Comment

by:Orcadian
ID: 37809530
Decompile did the trick.  Thanks!
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 75
ID: 37809532
Man, I'm on a roll with Decompile today ... 3x , lol.

cool.mx
0
 

Author Comment

by:Orcadian
ID: 37809534
Haha, that's great.  That Decompile and Compact context menu link looks useful, but the download link on their site is broken.  Do you know of another place I can get it?
0
 
LVL 75
ID: 37809542
Well, I just got to the link.  The site has been intermittent recently ... try again.  If you cannot get there ... let me know.

Yes ... that is MUST HAVE.  I use it daily.  Be SURE to open in Notepad first and tweak the folder paths for your installation of Access. You can also a entries for ACCDA, ACCDE (Compact only of course) ... and MDB/E/A also.

mx
0
 

Author Comment

by:Orcadian
ID: 37809607
The link to the website works (http://access.mvps.org/access/modules/mdl0039.htm), but on their site, when I click on "Download AccessReg.Reg" I get a 404 file not found error.
0
 
LVL 75
ID: 37809635
OOPS ... Humm. Bummer.

OK ... attached is the basic file ...with A2010 stuff ... easy to tweak for whatever version .
I renamed .REG to .TXT to upload.  Open in NotePad, tweak as necessary, then change back to .REG and double click to add to Registry.

Quick and simple.

mx
RightClickCompactDecompile2010-W.txt
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

757 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

19 Experts available now in Live!

Get 1:1 Help Now