Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2465 - Don't know why

Status
Not open for further replies.

PurpleUnicorn

Programmer
Mar 16, 2001
79
US
I am getting the following the error “2465 Microsoft Access can’t find the field “|” referred to in your expression” from the following piece code.

[blue]
If Me!Loc = "REQ" Then
Me![COND] = "-----"
Me!PRICE = 0
Me!QUANTITY = 0
Me!MFG = "---"
Me!Loc = "RFQ"
Me!PARTNO = "---"
Me!DC = "---"
Me!P_Box = ""
Me!QTY = 0
Me!TARGET = 0
Me!Text42 = ""
Me!LEAD_TIME = ""
Me!Description = ""

End If
[/blue]
This code is the last to run in the form “before_update” procedure. It is followed by the End Sub statement.
If I comment out all of the code between the if – end if statements, the code runs error free. Once I include even one line of the code – the 2465 error is generated. Any suggestions??

Thanks
 
Wouldn't swear to it but I think the problem may be the bang separator. Try using the dot instead: Me.COND =

Larry De Laruelle

 
Thanks for the speedy reply. I changed all to dots - same error. The funny thing is that I am getting an error message - but the code executes. I am completely baffled.

Nancy
 
And what about a STOP insstruction before the If and then stepping thru the code with the F8 key ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Then perhaps the error is somewhere else?

I've seen this error once when I referenced the current form with the me keyword in [brackets]

[tt][me]![txtSomeControl][/tt]

The bang (!) is what's used in all Microsoft documentation/help files I've seen, and I've never encountered any errors with that, but a very few times actually seen some errors with the dot (.).

Another way of referencing, is:

[tt]If Me("Loc").value = "REQ" Then
Me("COND").value = "-----"
...[/tt]

And one other thing, that might be a problem (seldom, I agree, but still), is using the same name on the control as the field it's bound to. You will see in much of the samples here at Tek-Tips that text controls are prefixed txt, combos cbo...

Else I'm also interested in the result of PHV's suggestion, but perhaps include the whole before update event in your debugging?

Roy-Vidar
 

Thanks for the reply.

I did debug and step through. Oddly - I don't get the error when I step through. I also created a new application and imported everything - thinking something was corrupt. Still getting the same error.

Nancy
 
Hi

I tend to agree with Roy "Then perhaps the error is somewhere else?",

You have compiled the code in your Db to check for syntax errors haven't you?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks to all who responded. In response to Ken - yes I was able to compile the form. In response to Ray - I think you are right about the error being somewhere else. When I debug and step through - I do not get the error.

I am in the process of reconstructing the form. It is a form that someone else created. I made a few changes (that I thought were minor changes) which somehow caused the error. I have taken the original form and am re-doing my changes line by line. So far, so good. If I figure out the actual cause of the error I will post - but somehow I think it will remain a mystery.

Thanks again,
Nancy
 
I finally had a chance to redo the form. I found the location of the problem to be in the error handling of a completely different procedure than I originally thought. I am still clueless as to why it is a problem. Here is the code:

[blue]
Err_ExitButton_Click:
If Err.Number <> 3021 Then
MsgBox Err.Description
End If
Resume Exit_ExitButton_Click
[/blue]

If I remove the entire "if" statement - no error. If I only include the "Msgbox Err.Description" or the entire "if" statement - I get the error. Any suggestions would be appreciated.

By the way, the error handling code was commented out when I got the form - now I know why!

Nancy

 
Err is a function in the VBA library that returns a reference of ErrObject. Check that the reference to the VBA library is not missing.
 


Thanks for the reply. The references are in place - I have similar code throughout the application that is all working just fine.

Nancy
 
Do you mean:

[tt]Err_ExitButton_Click:
'If Err.Number <> 3021 Then ' No current record
' MsgBox Err.Description
'End If
Resume Exit_ExitButton_Click[/tt]

works? If so, I think it means there is an error somewhere in the routine (or a sub or function not having errorhandling called by this routine), but the error object is cleared by the Resume statement. Perhaps if we see the entire code from this routine (pay special attention to form references), or any subs/functions this routine calls that does not have any errorhandling.

One trick to find where it might be, is to comment the line at top starting with "on error...". This would normally highlight the offending line - or if this routine is called from another routine having errorhandling, the error get's trapped there, comment that "on error..." too...

If this is not it, then my next thought would be form code corruption, but that would normally have been "removed" by creating the form from scratch or importing all, so do believe there might be some referencing error somewhere...

Roy-Vidar
 
Yes, it works when the entire "if" statement is commented out. Here is the code:

[blue]
Private Sub ExitButton_Click()
On Error GoTo Err_ExitButton_Click

Dim tempCompany, tempAddress, tempContact, tempTel, tempFax, tempEmailAddress As String
Dim tempStreet, tempCity, tempState, tempZip As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
[/blue][green]
tempCompany = Me!COMPANY.Value
tempAddress = Me!Address.Value
tempContact = Me!Contact.Value
tempTel = Me!Tel.Value
tempFax = Me!Fax.Value
tempEmailAddress = Me!Email_Address.Value
tempStreet = Me!StreetAddress
tempCity = Me!CITY
tempState = Me!STATE
tempZip = Me!ZIP

DoCmd.GoToRecord acDataForm, "myform", acNewRec

Me!COMPANY = tempCompany
Me!Address = tempAddress
Me!Contact = tempContact
Me!Tel = tempTel
Me!Fax = tempFax
Me!Email_Address = tempEmailAddress
Me!StreetAddress = tempStreet
Me!CITY = tempCity
Me!STATE = tempState
Me!ZIP = tempZip
Me![PrefixBox] = ""
[/green][blue]
Exit_ExitButton_Click:
Exit Sub

Err_ExitButton_Click:
If Err.Number <> 3021 Then
MsgBox Err.number & " " Err.Description & "ExitButton Click"
End If
Resume Exit_ExitButton_Click

End Sub
[/blue]

When I comment out all of the code I have highlighted in green - I still get the error. The "Save Record" caused the "Form_BeforeUpdate" procedure to run - are you saying that the error could be in the "Form_BeforeUpdate" code?

In addition - I did not recreate the form from scratch. Someone else created the form and I made changes. I initially thought that I caused the problem, but the problem exists in the original version. The designer simply commented out the error handling code so it appeared to work just fine.

 

I think I have finally found the problem. The BeforeUpdate code contains a bunch of updates/inserts to other tables. The last such update starts out:

If some condition then
docmd.cancelevent
it continues on to add a record (via recordset) to a table.

I have never used CancelEvent - so I am somewhat unfamiliar with its usage - but, the code seems to behave the same whether or not the docmd.cancelevent statement is included. However, without it, I no longer get the error.

Can someone explain the usage of CancelEvent and possible explain why it seems to be the cause of my error?

Thanks!
Nancy


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top