Invalid procedure call or argument error

Lopez, Ahiezer 236 Reputation points
2024-06-04T21:28:57.5766667+00:00

When pressing a command button the code below is executed, and it results in an error as seen in the picture. In addition, I seem to be the only user with this issue. My coworkers don't mention having this issue. I never had this issue until about a month ago.

Cmd button Code: Private Sub cmdCheck_Click()

On Error GoTo Err_Close_Jobs

Dim i As Integer

' check in our list

If MySel(Me!Cat) Then

' already in list - remove

CheckItems.Remove CStr(Me!Cat)

Else

' not in the list - add it

CheckItems.Add Me!Cat.Value, CStr(Me!Cat)

' Debug.Print CheckItems

End If

Me.ckSel.Requery

Exit_Close_Jobs:

Exit Sub

Err_Close_Jobs:

MsgBox Err.Number & "/" & Err.Description

Resume Exit_Close_Jobs

End Sub

Code:

Public CheckItems As New Collection

Private Sub cmdCheck_Click()

On Error GoTo Err_Close_Jobs

Dim i As Integer

' check in our list

If MySel(Me!Cat) Then

' already in list - remove

CheckItems.Remove CStr(Me!Cat)

Else

' not in the list - add it

CheckItems.Add Me!Cat.Value, CStr(Me!Cat)

' Debug.Print CheckItems

End If

Me.ckSel.Requery

Exit_Close_Jobs:

Exit Sub

Err_Close_Jobs:

MsgBox Err.Number & "/" & Err.Description

Resume Exit_Close_Jobs

End Sub

User's image

Image

Access
Access
A family of Microsoft relational database management systems designed for ease of use.
400 questions
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
881 questions
Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,172 questions
{count} votes

Accepted answer
  1. Albert Kallal 5,256 Reputation points
    2024-06-12T17:30:57.27+00:00

    Check items is a collection. If the item is not in the collection, then a error occurs. You need to change the break mode settings in VBA. Tools->options, general tab, and choose the option "Break on unhandled Errors"

    VBA collections don't have a built in function to test for existence in the collection, so error trapping is a workaround for this feature.


5 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.