undo function

N

ngan

I have a function that hides or unhides certain fields based on if a
calculated field is Yes or No.

In the underline query, I have a calculated field called "Continue" with an
IIf([field1]>[field2], "Yes", "No").

when a field is updated or a user moves from one record to another, the
event procedure runs: If [continue] = yes then certain fields are visible.
if no then certain fields are hidden.

However, if someone hits the esc button a couple times to undo their
changes, the function doesn't run. So if the the record originally had
continue = no and the user change the info so it would =yes and then they
undo the changes, the continue is still no, but the fields are still visible,
when they should be hidden.

Thanks.
 
J

John Smith

The only place to trap that is in the *form* KeyPress event, but don't forget
to set KeyPreview to Yes.

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then ShowFields
End Sub

Assuming that you have a sub called ShowFields that sets the visibility of
these fields.

HTH
John
 
Top