>Hi,
>I have a form with 10 textboxes. The form
>has a menu, with "print preview" being one
>of the functions in the menu. User can alter
>the contents in any of the textboxes. My problem
>is : when user makes changes to a textbox value and
>then immediately selects the "print preview" button,
>the last textbox that was altered does not get
>changed and shows only its original value (value
>before the change) in the preview window.
>
>My temporarily solution is after all the changes
>are made to the textboxes, user has to click the
>next record button and then prev record button once
>to get back to the same record. This way every textbox
>including the last one altered would get updated, and
>the user can print the new update record correctly.
>
>Could someone tell me how i can get the changed texboxes
>updated right when i select a menu function without
>going thru the extra step i am doing now?
>Thanks for any help.
>
>JW
See the code bellow to fix the problem. In some cases (like using hotkeys to activate buttons) the valid of textbox is not fired, thus the value is not updated.
local oObj, nIndex, i
if type('thisform.activecontrol.name')='C'
oObj = .activecontrol
if upper(m.oObj.baseclass) == "GRID"
nIndex = m.oObj.activecolumn
for i=1 to m.oObj.columncount
if m.oObj.columns(m.i).columnorder = m.nIndex
nIndex = m.i
exit
endif
endfor
oObj = m.oObj.columns(nIndex)
oObj = evaluate("m.oObj." + m.oObj.currentcontrol)
endif
if proper(m.oObj.baseclass)='Textbox' and not empty(m.oObj.controlsource) ;
and !(m.oObj.value==evaluate(m.oObj.controlsource))
m.oObj.value = m.oObj.value
lReturn = m.oObj.valid()
if (vartype(m.lReturn)='N' and m.lReturn = 0) or m.lReturn = .f.
return .f.
endif
endif
endif
If it's not broken, fix it until it is.
My Blog