Share via

"Run-time error "2427"

Anonymous
2012-03-24T16:04:54+00:00

Why would I get the following error when I try to run the code shown below?

"Run-time error '2427': You entered an expression that has no value."

The error occurs at the "If ctl.Value = True", and I have verified that ctl is a CheckBox control with the Add Watch feature.

Dim selectedTrainingEvent As String

Dim ctl As Control

For Each ctl In Me.Controls

    With ctl

        Select Case .ControlType

            Case acCheckBox

                If ctl.Value = True Then selectedTrainingEvent = ctl.Name

        End Select

    End With

Next

Any help would be greatly appreciated.

Dean

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

Answer accepted by question author

HansV 462.6K Reputation points
2012-03-24T16:16:00+00:00

Have you placed one or more check boxes in an option group? If so, those check boxes don't have a value of their own. Instead, the Option Value of the check box that is ticked becomes the Value of the option group (so you won't have to loop through the check boxes - simply look at the value of the option group)

Was this answer helpful?

6 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-03-27T18:26:23+00:00

    Thank you very much,

    That is exactly what my problem was.

    Regards,

    Dean Hornsby

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments