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:

  1. create new form
  2. specify recordsource form (i.e., make bound form)
  3. add subform control (note: there no need assign sourceobject subform control)
  4. set form beforeupdate property [event procedure]
  5. add following code form's code module:

    private sub form_beforeupdate(cancel integer)     doevents end sub 
  6. make change data on main form
  7. click directly on subform control
  8. receive error message noted in question

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -