How to catch UNDO of a check box?

G

Guest

Hi!

I have a check box with a label in a form. All I want to do is to keep the
label text consistent with the checkbox state. (Say label should say
"checked" if the checkbox is checked and "unchecked" if it is unchecked).

I've put code in the Form's CURRENT function and the check box's AFTER
UPDATE function to update the label text according to the checkbox value.

I still had problems with processing UNDO events (remember, checkboxes do
NOT have an ONUNDO event!).
I modified the Form's ONUNDO to update the label text according to the
checkbox's OLDVALUE value. That worked great, except for two cases!

CASE 1
That case is someone modifying the checkbox (whose AFTERUPDATE fires and the
label is changed properly), then the user moves to the next record (CURRENT
fires for the next record, and everything works for the next record). But
then the user does UNDO! Access returns to the previous modified record but:
Form's ONUNDO does not fire at all and CURRENT fires with the changed (not
original) value of that record. But the change to the checkbox gets undone
nevertheless. So the label is wrong.

CASE 2
This case is similar to case 1, except the user goes to the next record and
then comes back to the changed record. If the user does UNDO then, the Form's
ONUNDO does not fire (nothing fires at all, as far as I can see). But the
change to the value of the checkbox gets undone.

Any ideas?

Thanks a lot,

- Igor

P.S. Microsoft's KB Article regarding AfterUpdate events fails to call the
AfterUpdate event in the cases 1 and 2 above.
 
G

Guest

What you could do is do a requery of the current record (so a commit).
When the requery is processed also the form_current record is triggered and
there you can actualize the label as I presume will be already the case.
 
G

Guest

I have several questions about yuor suggestion.

1. When do you force requery of the current record? In what callback?

2. It seems that Form_Current being called is no indication of an inability
to later UNDO what has been changed before Form_Current (see my cases 1 & 2
-- both involved moving off to another record and a corresponding
Form_Current.

- Igor
 
A

Allen Browne

A simple solution would be to replace the attached label with a text box.
Set its ControlSource to:
=IIf(([MyCheckbox]), "Checked text", "Unchecked text")
 

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