Access VBA refer to a textbox on Active Form -
i know how refer item on form choosing form, i.e. forms!frmmyform![control].value
. have code that finds form open, , executes code variable, , it's not working. think need refer control using activeform, rather explicit form name, things i've tried accomplish haven't worked.
here's code.
private sub orderbutton_click() ' docmd.setwarnings false ' currecord = forms!frm_ec_all![l#].value getid = forms!frm_mainmenu!associdbox ' me.lbox.value = currecord ' if currentproject.allforms("frm_ec_all").isloaded = true rightform = "frm_ec_all" elseif currentproject.allforms("frm_ec_ec#").isloaded = true rightform = "frm_ec_ec#" elseif currentproject.allforms("frm_ec_holds").isloaded = true rightform = "frm_ec_holds" elseif currentproject.allforms("frm_ec_l1").isloaded = true rightform = "frm_ec_l1" elseif currentproject.allforms("frm_ec_l1_l2").isloaded = true rightform = "frm_ec_l1_l2" elseif currentproject.allforms("frm_ec_l2").isloaded = true rightform = "frm_ec_l2" elseif currentproject.allforms("frm_ec_l34").isloaded = true rightform = "frm_ec_l34" end if ' me.refresh ' docmd.runsql "update tbl_cqueue set order1 = -1, order1date = [l#] = " & currecord docmd.close acform, "frm_requests", acsaveyes docmd.close acform, rightform, acsaveyes ' docmd.openform rightform, acnormal, , , , acwindownormal ' dim currentform form: set currentform = screen.activeform msgbox "current form " & currentform.name ' currentform.timeractivatedlabel.visible = true ' getid = forms!frm_mainmenu!associdbox currecord = forms!currentform![l#].value ' docmd.runsql "update tbl_data set tbl_data.[associd] = " & getid & " , tbl_data.[tsstartall] = tbl_data.[associd] null , tbl_data.[l#] = " & currecord ' forms!currentform!idfieldbox.value = getid ' docmd.setwarnings true ' end sub
i error on line currentform.timeractivatedlabel.visible = true
. error says "database can't find form 'currentform' referred in macro expression or visual basic code."
so sees form open in background , stores "rightform", closes whichever form is, opens again, , try work set active form currentform
, , it's supposed set textboxes , runs sql statement, etc. needs know form's name , it's not correctly grabbing currentform
use form's name.
any ideas? thanks.
woops, found answer right after posting!
screen.activeform![timeractivatedlabel].visible = true
is working great me.
thanks anyway!
Comments
Post a Comment