Solved

Compile Error: Can't find project or library

Posted on 2011-09-23
10
712 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

751 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