vba - Error message in Access form with both manual and calculated data entries -
my access 2010 form used input data. fields manually (type in or choice dropdownlist), other fields precalculated values depending on input data. additional code controls enabling or disabling input fields dependent input data (ensuring data consistency).
my problem: when choose value (from dropdownlist) in field switch next field (any method: mouse/tab/code) , try enter value, [erroneous] error message "another user" (obviously own vba code) has modified record , saved before own changes saved. ok , second trial input data successful.
i tried me.recalc , me.refresh @ different positions in code without eliminating nasty error. how can tell access 2010 save input data in field before starting running code [mypreviousfield_afterupdate()] ?
docmd.runcommand accmdsaverecord unfortunately not work @ all, problemativ fields unbound. it's mix of related bound , unbound fields access not handle 1 expect. disabling error messages or record lock, or me.undo or me.myfield1.undo not work @ either.
however, found work-around myself. note setting focus on other field may push access save values avoiding erroneous error message, fails. following code works not either practicable few changes in form:
dim myfieldval1 variant, myfieldval2 variant ', … [all unbound fields] private sub myfield1_change() … if not isnull(me![myfield1]) myfieldval1 = me![myfield1] if not isnull(me![myfield2]) myfieldval1 = me![myfield2] … ' same unbound fields on form call saveallvalues(me.name, me.currentrecord) … … ' here code change field without me.refresh … me![myfield1] = myfieldval1 me![myfield2] = myfieldval2 … ' same unbound fields on form me.refresh end sub '=================================================== sub saveallvalues(byval formname, byval currec) docmd.gotorecord acdataform, formname, acfirst docmd.gotorecord acdataform, formname, acgoto, currec end sub
the whole procedure tedious above code must implemented each unbound field: myfield2_change() etc. etc.
it worked correctly quite while, after minor other changes @ other places in code, errors appears reproducibly again ! result depends on access' last code compilation, leading other erratic problems. module corrupt (database repair not correct anything). have live erroneous error or begin designing new form scratch again…
maybe impossible mix bound , unbound fields on same form, 1 has no other way use subforms bound data ?
Comments
Post a Comment