Solved

Compile Error: Can't find project or library

Posted on 2011-09-23
10
699 Views
Last Modified: 2012-05-12
I don't get an error that one of my users get. I had them send me a screen shot of the error message and of the line that would be highlighted. What can I do to make sure they don't get this?

The complete line is not visible in the imgage, but here it is:
DoCmd.SearchForRecord , "", acFirst, "[ProgramID] = " & Str(Nz(Screen.ActiveControl, 0))
 error message offending line
0
Comment
Question by:dlogan7
10 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36586900
This is often caused by a broken or missing reference.

From the VBA Editor, select Tools / References, and see if any are listed as missing.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36586960
(No points) Just to be precise about Patrick's advice - you must check this on the 'problem' machine, not your development machine.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36587087
Curious why you need the Str() function at all?

Doesn't this work?

DoCmd.SearchForRecord , "", acFirst, "[ProgramID] = " & Nz(Screen.ActiveControl, 0)
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:dlogan7
ID: 36587780
Before posting my question I checked to see if there were any missing references. I've never known what causes that, but do know to look for it. I guess I'd say it really baffles me that a user could have a missing reference when I don't. Would that be related to him using a version that's different from mine. Could it also have to do with Office Updates? Like I said, I really don't know what's going on with missing references.

mbizup: At some point along the way an expert must have recommended the Str() function to get around a problem I was having at that time.

Since I'm not going to walk the user through looking for a missing reference, I made the modification recommended to remove the Str() function and will wait to hear if that fixes it.
0
 

Author Comment

by:dlogan7
ID: 36588086
Well, that didn't work. I had him get to the references list and send me a screen shot of that. I am posting below, both his and my screen shot. I could have had him find the missing reference, but surely there's something I can do on my end to keep this from happening. Right?
 His Mine
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36588093
dlogan7,

If it really is a reference problem, then removing the Str() won't resolve the issue; some other perfectly innocent function call will now throw the error.

Different versions of Office can certainly cause referencing issues.  What libraries are you referencing?

Patrick
0
 
LVL 75
ID: 36588145
dlogan7:

Is [ProgramID] Numeric or Text ?

mx
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 36588249
Get rid of the reference to Excel, and use late binding instead.

So, instead of:

Sub foo()

    Dim xlApp As Excel.Application
    Dim xlWb As Excel.Workbook
    Dim xlWs As Excel.Worksheet
    Dim xlRange As Excel.Range
    'etc

    Set xlApp = New Excel.Application
    Set xlApp = xlApp.Workbooks.Add
    'etc.

End Sub

Open in new window



do this:


Sub foo()

    Dim xlApp As Object 'Excel.Application
    Dim xlWb As Object 'Excel.Workbook
    Dim xlWs As Object 'Excel.Worksheet
    Dim xlRange As Object 'Excel.Range
    'etc

    Set xlApp = CreateObject("Excel.Application")
    Set xlApp = xlApp.Workbooks.Add
    'etc.

End Sub

Open in new window

0
 

Author Comment

by:dlogan7
ID: 36588615
MX,

ProgramID is numeric.

Patrick,

"What libraries are you referecning?" I included a image showing a list of mine and his. Mine is the second one. Again, I don't know that I ever make any changes to the references unless I get an error when running debug.

Question: Is it really necessary for me to reference these 3 libraries:
Access 14.0
Excel 14.0
Office 14.0
Looking at the names, one would assume, anything included in Office would also be in Access and Excel.

As for your late binding recommendation, when I went to make those changes there was no need to make a change. That's what I was already doing.

So, I figured I could simply uncheck the reference to Excel 14.0. Debug didn't find any issues, so I am sending it back to the client to see if that fixes it.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36588876
Yes, if your code is already structured as if for late binding, then removing the reference altogether and doing a debug/compile should resolve this.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

808 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