vba - Access Public Function for Maintain Combo Lists -
i have on 40 combo controls in application. working on developing public function, put in not in list event of every combo. goal have 1 continuous pop form, open, if user says want add new value combo. open form command pass open args
- record source
- the control source 1 text box on continuous form (generically type)
- the label control source.
i'm having trouble getting pass open args. debug.print parts of args, can split them, when passed (inconsistent results getting open args pass correctly, try debug), , cannot seem set record source pop form correctly. i've tried doing 1 @ time, , still can't seem it.
this public function: option explicit
public function typenotinlist(ctl control, arg1 string, arg2 variant, arg3 string) on error goto err_typenotinlist dim msg, style, title 'arg1 row source of combo, passed recordsource frmaddtypeval form 'arg2 control source of combo, passed control source text box in frmaddtypeval form 'arg3 label of combo, used messages, , label of text box in frmaddtypeval form msg = "the " & arg3 & " entered not in " & arg3 & " list, add now?" style = vbyesno title = "type or listing must maintained" response = msgbox(msg, style, title) if response = vbyes ctl.undo docmd.openform "frmaddtypeval", acnormal, , , , acdialog, arg1 & "|" & arg2 & "|" & arg3 ctl.requery end if exit_typenotinlist: exit function err_typenotinlist: msgbox err.description resume exit_typenotinlist end function
this how calling it, in 1 combo's not in list event: option explicit private sub fkaudittype_notinlist(newdata string, response integer) dim a1 string dim a2 string dim a3 string
a1 = me.fktypexyz.rowsource a2 = "txtxyztype" a3 = me.lbltypexyz.caption typenotinlist me.fktypexyz, a1, a2, a3 response = acdataerrcontinue end sub
that should calling public function, , passing 4 parameters.
this form load of generic continuous pop-up form, called frmaddtypeval: option explicit
private sub form_load() dim varargs() string varargs = split(me.openargs, "|") me.form.recordsource = varargs(0) me.txttype.controlsource = varargs(1) me.lbltype.caption = varargs(2) end sub
when run is, debug.print (s) give me following:
ctl = fkfktypexyz arg1 = select tblxyztype.id, tblxyztype.txtxyztype tblxyztype order tblxyztype.txtxyztype; arg2 = fkxyztype arg3 = xyz type openargs =
i each value, open args null. heck, beck?
can guide clueless coder? lol
thanks!
i edited update code, changes made. it's working! @ least first part of process. openargs passed , pop-up form works correctly. when click close on form, i'm on form notinlist combo. resumes it's process , message: text entered isn't item in list.
it know that's default notinlist message. thing is, public function supposed handle this. has, in if response = vbyes then
ctl.undo 'undo trying add value not in list yet
and after open form (which involve close of form, think)
ctl.requery 'requery combo, added value(s) can seen
anyone know how can adjust prevent message, not disable warnings?
thanks!
got it! in not in list, after call public function, have add:
response = acdataerrcontinue
this let's default error message take seat lol.
thanks help! going make setting every darn combo easier!!!!
Comments
Post a Comment