Checkbox value validation and events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a checkbox named "ckbFinished" on a sub form. The checkbox is bound
to a table field. If/when the user clicks on the checkbox, i want to test
the value of the checkbox to see if it is poulated. IF it is populated
(value=true) then a msgbox displyed to tell the user that updating this field
is not allowed--cancel action/change to checkbox. ELSE let the user change
the value of the checkbox to true. I have attached this to On Click event of
the checkbox:

Dim strValue As Boolean
strValue = Me.ckbFinished.Value

If strValue = True Then
MsgBox "Change is not allowed"
Cancel = True
Else
'Nothing - let the update happen
End If

Exit Sub

My problem is that when the field is unpopulated, the msgbox appears but the
field is populated when i move toa diff form-another problem. Need to save
record? IT also allows me to remove the check mark (true value). Having
problems :-) Any help please? Thanks
 
If the check box was changed to False, then it must have been True, so Undo
the change:

Private Sub chkFinished_AfterUpdate()
If Not Me.chkFinished.Value Then
MsgBox "No way!"
Me.chkFinished.Undo
End If
End Sub
 
Back
Top