vba - Error 2115: Macro/function set to BeforeUpdate/ValidationRule is preventing {pgm} from saving data in the field -
i have bound form subform. when make change main form , click on subform, following error:
the macro or function set beforeupdate or validationrule property field preventing {program name} saving data in field.
- if macro, open macro in macro window , remove action forces save (for example, gotocontrol).
- if macro includes setvalue action, set macro afterupdate property of control instead.
- if function, redefine function in module window.
if make change on main form, click on record selector box or press shift+enter save, , click on subform not error message.
it turns out culprit call doevents
in form_beforeupdate
procedure. simplest solution remove call doevents
.
in particular case, call doevents
buried deep down in call stack, sure follow of code paths or global search on doevents
.
to reproduce error:
- create new form
- specify recordsource form (i.e., make bound form)
- add subform control (note: there no need assign sourceobject subform control)
- set form beforeupdate property
[event procedure]
add following code form's code module:
private sub form_beforeupdate(cancel integer) doevents end sub
- make change data on main form
- click directly on subform control
- receive error message noted in question
Comments
Post a Comment