0

Is it possible to make it so that if a check is put in a check box that certain fields of the form are made so that the user cannot add data?

Form is asking for address, city, state, zip

Checkbox asks if the person is homeless

So wanting to make it so that if there is a check in the box that address info cannot be entered.

Else... if there is data in the address fields AND the box is checked that an error appears on the screen.

Help.

1 Answer 1

1

An example could look like that.

Private Sub chkHomeless_Click()
    If chkHomeless.Value Then
        With txtCity
            .Value = ""
            .Enabled = False
        End With
        With txtState
            .Value = ""
            .Enabled = False
        End With
    Else
        txtCity.Enabled = True
        txtState.Enabled = True
    End If

End Sub

You would need to add the code for the third TextBox and you might want to add a kind of Question if the textboxes should really be emptied when checking the box. Or you display in this case a kind of error message as you wrote in your post.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.