Solved Error 2465

smtazulislam

Member
Local time
Today, 02:52
Joined
Mar 27, 2020
Messages
808
Hi, I worked in this dB 1 years up nothing error.
Today I facing this error...
Code:
Private Sub cmdInsertData_Click()
If CurrentProject.AllForms("frmEmployeeEdit").IsLoaded Then
    Forms("frmEmployeeEdit").Form!sfrmFacilitiesEdit.Form.Items = Me.Text2
    DoCmd.Close acForm, Me.Name
End If
End Sub

Edit :
I compact & repair 2 times. but same error.
 

Attachments

  • Capture.JPG
    Capture.JPG
    79.1 KB · Views: 141
Comment out this line of Code:-

Code:
Forms("frmEmployeeEdit").Form!sfrmFacilitiesEdit.Form.Items

And see if that prevents the error occurring....
 
Code:
Forms("frmEmployeeEdit").sfrmFacilitiesEdit.Form.Items = Me.Text2
The control is named items? That would be dangerous because of reserved words.
 
1. "Items" is not a reserved word and not a property in the vba library. "Item" singular is a property of a collection but still not a reserved word.

I would never ever use that name, but it is not the cause of your problem.
I would however, rename both "Items" and "Text2". Give them better names
lstItems,
txtItemSelection


2. Your mistaken that code never ever worked. You can not set the value of a multiselect listbox in that way.
Your code should look like this
Code:
Private Sub btn_Click()
  Dim i As Integer
  For i = 0 To Me.items.ListCount - 1
    If Me.items.Column(0, i) = Me.Text2 Then
       Me.items.Selected(i) = True
       Exit Sub
    End If
  Next i
End Sub
 
For this to have been silent for as much as a year, the question is, what did you change on the form, even if it is not related to that button?

If you have not been playing around with various other aspects of the form, then did you perhaps have a Windows Update that included a patch to MS Office files? Sometimes the patches ancillary to a Windows O/S patch will touch a library or utility (like Access) and something will behave differently.

If no to both of those, the implication would be that this is the first time that code has actually executed, which is to say that you never clicked the control before, and that seems unlikely.
 
Hi, I worked in this dB 1 years up nothing error.
Today I facing this error...
Code:
Private Sub cmdInsertData_Click()
If CurrentProject.AllForms("frmEmployeeEdit").IsLoaded Then
    Forms("frmEmployeeEdit").Form!sfrmFacilitiesEdit.Form.Items = Me.Text2
    DoCmd.Close acForm, Me.Name
End If
End Sub

Edit :
I compact & repair 2 times. but same error.

Which line of code generates the error?
Without this basic information, it is not possible to advise how to proceed
 

Users who are viewing this thread

Back
Top Bottom