Run time error 2465

R

Rock

I'm trying to open an access db and upon loading or opening I get Run
Time Error 2465 Can not find field 'cmdLock' referred to in your
expression. When I go to Debug I see it highlight the line in
question:

frm!cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")

It seems OK, what am I missing?

One other strange thing, (well strange to me) is that this db is
located on a network drive. No one else has this problem, but me?
Any ideas?
 
T

Tom Wickerath

Hi Rock,

When an application works on other PCs, but fails on one PC, this is usually
a sign of a MISSING reference error on the affected PC. On this machine in
question, open any code module. Then click on Tools > References. Do you see
any of them marked as MISSING? You may need to refresh the references list
as well. Try adding some reference (any reference), clicking on OK to dismiss
this dialog box, then go right back in and remove the newly added reference.
Then try a Debug > Compile ProjectName, where ProjectName is the name of your
VBA project. Does your code compile without any errors on the affected
machine?

While you are looking at the references dialog, make a note of the
references that are checked off. Then try removing them one at a time. Each
time you remove a reference, try compiling your code. If your code compiles
okay after removing a checked reference, then you did not need that reference
to start with. It is always best to "starve" the references list. More
information here:

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

Rock

Hi Rock,

When an application works on other PCs, but fails on one PC, this is usually
a sign of a MISSING reference error on the affected PC. On this machine in
question, open any code module. Then click on Tools > References. Do you see
any of them marked as MISSING? You may need to refresh the references list
as well. Try adding some reference (any reference), clicking on OK to dismiss
this dialog box, then go right back in and remove the newly added reference.
Then try a Debug > Compile ProjectName, where ProjectName is the name of your
VBA project. Does your code compile without any errors on the affected
machine?

While you are looking at the references dialog, make a note of the
references that are checked off. Then try removing them one at a time. Each
time you remove a reference, try compiling your code. If your code compiles
okay after removing a checked reference, then you did not need that reference
to start with. It is always best to "starve" the references list. More
information here:

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

Tom Wickerath
Microsoft Access MVPhttps://mvp.support.microsoft.com/profile/Tomhttp://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________








- Show quoted text -

Thanks for the thoughts, I've look at the Module References there are
four checked, two of which I was unable to uncheck. The other two I
unchecked and complied, with no errors messages. That however did not
clear up the error 2465. I still get it. I thought to compare
another db to see which references were used and noticed that had two
others, I checked those two off on mine but same results. I do not
see any one listed with the word missing, I'm assuming it would
indicate that either in the name or at the bottom of the dialog page,
where I see 'location' and such.

The two that I can not uncheck:

Visual Basic For Applications and Microsoft Access 9.0 Object Lib

The two I can uncheck but get the same result:

IAS Help on COM Comptent and IAS RADIUS Protocol 1.0 Lib

Any other thoughts/ideas?
 
T

Tom Wickerath

Hi Rock,
The two that I can not uncheck:
Visual Basic For Applications and Microsoft Access 9.0 Object Lib

Correct. Every Access application requires these first two references.
The two I can uncheck but get the same result:
IAS Help on COM Comptent and IAS RADIUS Protocol 1.0 Lib

If you can uncheck these, without producing a compile error, then you simply
do not need them. Don't add these back in.

Have you tried substituting the keyword "Me." in place of "frm!", as in:

Me.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")

This assumes that a control named "cmdLock" is present on the same form, and
that this control includes a caption property.

Do you have the two very important words "Option Explicit" as the second
line of code at the top of every code module? Please see this gem tip for
more information:

Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

Rock

Hi Rock,


Correct. Every Access application requires these first two references.


If you can uncheck these, without producing a compile error, then you simply
do not need them. Don't add these back in.

Have you tried substituting the keyword "Me." in place of "frm!", as in:

Me.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")

This assumes that a control named "cmdLock" is present on the same form, and
that this control includes a caption property.

Do you have the two very important words "Option Explicit" as the second
line of code at the top of every code module? Please see this gem tip for
more information:

Always Use Option Explicit
http://www.access.qbuilt.com/html/gem_tips.html#VBEOptions

Tom Wickerath
Microsoft Access MVPhttps://mvp.support.microsoft.com/profile/Tomhttp://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________










- Show quoted text -

Thanks Tom...I tried changing FRM to ME and I recieved "invalid use of
ME keyword". I tried both ME. and ME! with the same result. I also
noticed that the Option Ex was not present in the code, I added it but
again, same result.
 
T

Tom Wickerath

Is this code in a stand-alone module (ie. on the Modules tab)? That would
explain the error on using the Me keyword. I had made the assumption that
your code was associated with a form module.

I am able to reproduce error 2465, using the code shown below in a
stand-alone module, if the form "MyForm" is open in normal view but there is
no control named "cmdLock":

Option Compare Database
Option Explicit

Public Sub Test123(block As Boolean)

Dim frm As Form
Set frm = Forms![MyForm]

frm!cmdLock.Caption = IIf(block, "Un&lock", "&Lock")

End Sub


Please verify that you have a control on your form named "cmdLock". Please
also post the entire procedure, and how this procedure is called (Autoexec,
etc.).


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top