Solved

Compile Error: Can't find project or library

Posted on 2011-09-23
10
697 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dynamically Reorder List Box 4 37
User Level Security 6 38
Why get error when delete all records on a sub-form 2 15
Field naming convntions - MS Access 7 24
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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.

776 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