0

I had a "Compile Error: Can't find project or library" error when opening a database that I have programmed on a new workstation (that I do not typically use).

The really odd thing is that the highlighted code is LCase which is something extremely basic. That the reference for this could be missing in even a freshly installed standard edition of MS Access is unlikely.

Having googled this phenomenon I have read that sometimes Excel Files don't grab all necessary refrences when they are copied. Chip Pearson's excellent article explains which references are needed.

So I tried to go check if all references are available, when stranger still, I couldn't even access the Tools>References in Access because it was grayed out.

Why would this happen and how can I fix it?

Any advice or hints on how to investigate this are appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
rohrl77
  • 3,277
  • 11
  • 47
  • 73

2 Answers2

1

VBA references are not available for viewing or editing in an .mde or .accde Access database. It must be a .mdb or .accdb to view references.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Bob Allen
  • 11
  • 1
  • This wasn't the case with my database, but still, it might help as an additional point to check for someone else. +1 – rohrl77 Mar 13 '21 at 12:16
0

Sometimes things move quicker than expected. Upon searching yet another time, I found the solution to the problem.

In needed to add VBA infront of UCase, LCase, or Space . Apparently on some machines linking to compiled DLL files causes this problem.

VBA.LCase, etc. solves it.

rohrl77
  • 3,277
  • 11
  • 47
  • 73
  • You should still check Tools -> References, it should available when no code is running (i.e. not while debugging). Click the Stop/Reset button in the toolbar, if necessary. – Andre Jan 26 '16 at 10:05
  • I tried that and it wouldn't let me. I even attempted to shut down the database and reopen without running any code at all before looking at it, but it remained grayed out. Access seem to check the code even on startup... I was rather surprised by this. – rohrl77 Jan 26 '16 at 10:12
  • 1
    Odd. The only other thing I can imagine: make sure you have a module of the **current** database selected in the project tree, not one of an add-in or template. – Andre Jan 26 '16 at 10:19
  • 1
    In the Immediate window, what does `? VBE.ActiveVBProject.FileName` show you? Is it the same as what `? CurrentDb.Name` shows you? – HansUp Jan 26 '16 at 14:23
  • @HansUp No. I get an extended path for the VBE version that references the server. The `CurrentDb.Name` only gives me the path from the drive onward. – rohrl77 Jan 26 '16 at 14:57
  • OK. Then does `? VBE.VBProjects.Count` show you a value greater than 1? – HansUp Jan 26 '16 at 14:58
  • That was not what I hoped to hear. So that means I'm stumped. Still you should not have to use `VBA.LCase` instead of just `LCase` unless you have a problem with references. Can you share a copy of your database? – HansUp Jan 26 '16 at 15:23
  • @HansUp Thanks for the offer to look into it. Today I'm back at my regular computer, so I can't even reproduce it. I also can't share the dta base. Well... not unless I want to get fired. Which... hang on... let me see if I can upload this :- ) – rohrl77 Jan 27 '16 at 07:16
  • @HansUp would you mind looking at a different question I have? Perhaps your experience would help in getting at an answer to another problem I have that is hard to pin down. http://stackoverflow.com/questions/34949132/access-openreport-not-working-with-where-condtion/34949223?noredirect=1#comment57632579_34949223 – rohrl77 Jan 27 '16 at 08:46
  • Since the new report operates correctly, you might try decompile in case the old report is corrupted. See [How does one decompile and recompile a database application?](http://stackoverflow.com/q/3266542/77335) I'm not confident that is the solution for your problem, but it's useful to learn about decompile. – HansUp Jan 27 '16 at 14:47