Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

Compile Error: Can't find project or library

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
Dale Logan
Asked:
Dale Logan
1 Solution
 
Patrick MatthewsCommented:
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
 
peter57rCommented:
(No points) Just to be precise about Patrick's advice - you must check this on the 'problem' machine, not your development machine.
0
 
mbizupCommented:
Curious why you need the Str() function at all?

Doesn't this work?

DoCmd.SearchForRecord , "", acFirst, "[ProgramID] = " & Nz(Screen.ActiveControl, 0)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Dale LoganConsultantAuthor Commented:
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
 
Dale LoganConsultantAuthor Commented:
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
 
Patrick MatthewsCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
dlogan7:

Is [ProgramID] Numeric or Text ?

mx
0
 
Patrick MatthewsCommented:
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
 
Dale LoganConsultantAuthor Commented:
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
 
Patrick MatthewsCommented:
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now