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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error '2465'

Status
Not open for further replies.

byurow

Programmer
Jul 7, 2002
111
0
0
US
I have an Access 2003 database that is acting pretty strangely. The controls on the form are all unbound and I am using DAO to reference the tables / queries. I have a date field on the form that when clicked will open an ActiveX calendar control. When the date is selected on the calendar, it puts the date into the text box. I then hide the calendar. I need to set the focus to another field before hiding the calendar. My code use to work! Now, I get the Runtime Error '2465' can't find field.... error. The problem is when I choose to debug and just hit the continue button, the code runs fine. Also, the first time I run the code it runs fine. My code is as follows:

Code:
Private Sub TxtDevice_Warranty_Expire_GotFocus()
    
    TxtDevice_Warranty_Expire.SelStart = 0
    TxtDevice_Warranty_Expire.SelLength = Len(TxtDevice_Warranty_Expire.Text)
    lngCalID = 8
    Me.CalPurchase_Detail_Dates.Visible = True

End Sub
Code:
Private Sub CalPurchase_Detail_Dates_Click()
    
If lngCalID = 4 Then
    Me.TxtDate_of_Purchase.Value = Me.CalPurchase_Detail_Dates.Value
    Me.TxtQuantity_Price.SetFocus
ElseIf lngCalID = 5 Then
    Me.TxtSoftware_License_Expiration.Value = Me.CalPurchase_Detail_Dates.Value
    Me.CmdSavePurchaseDetail.SetFocus
'ElseIf lngCalID = 6 Then
'    Me.TxtHardware_Warrenty_Expire.Value = Me.CalPurchase_Detail_Dates.Value
'    Me.CmdSavePurchaseDetail.SetFocus
ElseIf lngCalID = 7 Then
    Me.TxtMaintenance_Support_Expire.Value = Me.CalPurchase_Detail_Dates.Value
    Me.TxtMaintenance_Support_Level.SetFocus
ElseIf lngCalID = 8 Then
    Me.TxtDevice_Warranty_Expire.Value = Me.CalPurchase_Detail_Dates.Value
    Me.CmdSavePurchaseDetail.SetFocus
End If

Me.CalPurchase_Detail_Dates.Visible = False

End Sub
I am not using any special characters and the code will run once I push continue. Any suggestions?????
 
Hi byurow,

On which line did you get the error?

Try to figure out, why at the first time it doesn't get the error?. (in other words: in which part of the 'IF' it's ok, and in which part it is getting the error)

[by the way, I think it would be a good idea to work with [blue]'SELECT CASE lngCalID ... END SELECT'[/blue], in place of all the 'elsif'.]

here is a link about this error code. might be helpful.
[link]http://bytes.com/forum/thread573492.html[/url]

Ja
 
Hi Ja,

Thanks for responding! The Line I am getting the error on is:

ElseIf lngCalID = 8 Then
Me.TxtDevice_Warranty_Expire.Value = Me.CalPurchase_Detail_Dates.Value
Me.CmdSavePurchaseDetail.SetFocus

Specifically the line:

Me.CmdSavePurchaseDetail.SetFocus

I changed it to a Case Statement with the same results. So while playing I decided to run the application on a different computer. I have both an Admin and a regular user account. Not thinking I ran the second computer with my regular user account while I ran the app on my original computer with my admin account. The code runs without error with my regular user account.

Maybe I should just trap the message and continue on??? Think that will work?

Brenda
 

Hi,

I am not that experienced, I cannot tell you for sure.

But have you looked at the link I gave you?
there is some advise from allen brown (he is great with access). There i saw that it can be that something is corrupted. with some suggestions how to try to fix it.

depends how much time you have to read...

I wish you luck... Ja
 
Which error number are you getting? There are a number of reasons why you may not be allowed to move focus. I do not think that this is a corruption problem.
 
Ja...I did look at the link and tried some of the suggestions...no luck.

Remou...I am getting Error No 2465. I am placing the focus on a text box that is visible on the form so I can't imagine why Access is throwing an issue.

My problem is that I don't understand why it works sometimes and not others. After playing around more yesterday, I discovered that after a while on my user account the issue happens there also. Could it be a memory issue? Perhaps after a while it just runs out? I am pretty good about closing my recordsets when the code has finished and can't find anything I've missed but was really hoping someone else had come across this issue.

I downgraded this application from 2007 and am wondering if perhaps something got messed up in the conversion. I will try re-creating the application and form to see if perhaps that could be the issue.

Any other suggestions?????

Thanks again Ja and Remou!



Brenda
 
Apologies, you had mentioned the error. It is an odd error, so it looks as if Ja is right, but it is puzzling that the error does not always occur. Some ideas that come to mind are to check if the control is visible, but in this case I would expect a different error; to check which control previously had the focus; and to check if you have Name AutoCorrect turned on. It may also be worth trying a copy of the form with no code except the section that sets focus and see if there are any problems.
 
Remou...Yes, the control is visible, an ActiveX calendar has the current focus and Name AutoCorrect is not on. I am in the process of recreating the form with just that code. I will let you know if that works in a minute. Thanks!




Brenda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top