Reputation: 5
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.
Upvotes: 0
Views: 134
Reputation: 12167
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.
Upvotes: 1