vba - MS Access runtime error 2115 -
in ms access, have 2 unbound combo-boxes: statebox
, dvpcbox
. statebox list of u.s. states , dvpcbox contains employee names query based on value of statebox.
i'm trying set value of dvpcbox equal first item in list. since list of employees based on value of statebox, need value of dvpcbox update every time statebox changes. tried following:
private sub statebox_afterupdate() me.dvpcbox.requery if (me.dvpcbox.listcount = 1) me.dvpcbox.setfocus me.dvpcbox.listindex = 0 //<-error here end if end sub
but got runtime error 2115 - macro or function set beforeupdate or validationrule property field preventing microsoft office access saving data in field.
the strangest thing me i'm not using beforeupdate event or validationrule (as far i'm aware.)
itemdata(0)
first combo box value. set combo equal that.
private sub statebox_afterupdate() me.dvpcbox.requery if (me.dvpcbox.listcount >= 1) me.dvpcbox.setfocus 'me.dvpcbox.listindex = 0 //<-error here me.dvpcbox = me.dvpcbox.itemdata(0) end if end sub
i changed listcount >= 1
because assumed wanted same thing when combo includes 2 or more rows.
Comments
Post a Comment