Share via

error 2424

Anonymous
2011-04-13T15:16:12+00:00

I have the following in my on current event for a form

Private Sub Form_Current()

On Error GoTo Error_Handler

    'Don't allow changes to finalised CIs

    If Me.finalise = True Then

        With Me.Form

            .AllowDeletions = False

            .AllowEdits = False

        End With

    End If

It works in a general sense, but it throws an error 2424 : "The expression you entered has a field, control or property name that Microsoft Office Access can't find." everytime I close the form. Why is it firing a current when a form closes? And how do I get around this as I do need to control edits, deletions based on each records Finalise value?

QB

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2011-04-13T17:50:45+00:00

    This does work, but it just worries me to be burrying an error like that.

    Unfortunately, the behavior of Access with event firing makes it necessary sometimes.  If you want to, you can localize the suppression to just the line of code that you know may raise an unwarranted error, either by setting a flag variable to indicate where you are in the code:

        Dim blnFinaliseCheck As Boolean

        ' ...

        blnFinaliseCheck = True

        If Me.finalise = True Then

            With Me

                .AllowDeletions = False

                .AllowEdits = False

            End With

        End If

        blnFinaliseCheck = False

    ... and testing that variable in your error-handling routine, or by specifying a separate error-handler for that section:

        On Error GoTo Finalize_Error

        If Me.finalise = True Then

            With Me

                .AllowDeletions = False

                .AllowEdits = False

            End With

        End If

        On Error GoTo Error_Handler

    It's possible that referring to Me!Finalise rather than Me.Finalise -- bang instead of dot -- would avoid the error.  I don't know, but it may be worth a try.

    By the way, in my code examples I've removed the ".Form" from "Me.Form".  "Me" is already a reference to the form, so there's no reason to tag on a ".Form" qualifier, though it does no harm.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-04-13T15:46:33+00:00

    This does work, but it just worries me to be burrying an error like that.

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2011-04-13T15:32:52+00:00

    The order in which events in a form occur is complicated and confusing, in particular if the form contains subforms. It's probably easiest to use your error handler to ignore error 2424.

    Was this answer helpful?

    0 comments No comments