Solved Error 2465 (1 Viewer)

smtazulislam

Member
Local time
Today, 04:57
Joined
Mar 27, 2020
Messages
806
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: 72

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 02:57
Joined
Jul 9, 2003
Messages
16,285
Comment out this line of Code:-

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

And see if that prevents the error occurring....
 

ebs17

Well-known member
Local time
Today, 03:57
Joined
Feb 7, 2020
Messages
1,950
Code:
Forms("frmEmployeeEdit").sfrmFacilitiesEdit.Form.Items = Me.Text2
The control is named items? That would be dangerous because of reserved words.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:57
Joined
May 21, 2018
Messages
8,555
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
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:57
Joined
Feb 28, 2001
Messages
27,236
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.
 

amorosik

Member
Local time
Today, 03:57
Joined
Apr 18, 2020
Messages
397
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

Top Bottom