Checkbox value validation and events

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
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top