Cancelling a Before Update event

G

Guest

I have a form with a subform. A combo box on the form determines the contents
of the subform. If this value is already set and the user attempts to chnage
its value, I display a warning with 'okcancel' options. If the user presses
cancel I want to revert back to the original value in the combo box and not
re-trigger the 'before update' event. How to do this???
Currently, I set Cancel = True and set cmbBox.value = cmbBox.Oldvalue,
however, I am still getting the 'before update' event retriggering. The value
in the combo box also does not revert back. I did notice that if I press the
ESC key it corrects everything.
 
R

Rick Brandt

mscertified said:
I have a form with a subform. A combo box on the form determines the
contents of the subform. If this value is already set and the user
attempts to chnage its value, I display a warning with 'okcancel'
options. If the user presses cancel I want to revert back to the
original value in the combo box and not re-trigger the 'before
update' event. How to do this???
Currently, I set Cancel = True and set cmbBox.value = cmbBox.Oldvalue,
however, I am still getting the 'before update' event retriggering.
The value in the combo box also does not revert back. I did notice
that if I press the ESC key it corrects everything.

Cancel = True
Me.ComboBoxName.Undo

(no need for OldValue)
 
M

Marshall Barton

mscertified said:
I have a form with a subform. A combo box on the form determines the contents
of the subform. If this value is already set and the user attempts to chnage
its value, I display a warning with 'okcancel' options. If the user presses
cancel I want to revert back to the original value in the combo box and not
re-trigger the 'before update' event. How to do this???
Currently, I set Cancel = True and set cmbBox.value = cmbBox.Oldvalue,
however, I am still getting the 'before update' event retriggering. The value
in the combo box also does not revert back. I did notice that if I press the
ESC key it corrects everything.


The subform's record save (and its associated events) occur
as the focus shifted out of the subform, way before you
selected a new value from the list. This means there is no
hope of canceling the subform's BeforeUpdate event in the
main form's combo box.
 

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