Solved

Compile Error: Can't find project or library

Posted on 2011-09-23
10
690 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
Comment Utility
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
Comment Utility
(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
Comment Utility
Curious why you need the Str() function at all?

Doesn't this work?

DoCmd.SearchForRecord , "", acFirst, "[ProgramID] = " & Nz(Screen.ActiveControl, 0)
0
 

Author Comment

by:dlogan7
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
dlogan7:

Is [ProgramID] Numeric or Text ?

mx
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now