Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function keys and validations
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00665069
Message ID:
00665338
Views:
23
Thanks a lot, Vlad. I was thinking in the same direction (as you see), but didn't think about grid.

Do you want to document this?

Thanks again.

>Hi!
>
>Nadya, there was a thread recently at the Russian VFP Club where I posted a code sample <s>. The thread title is "Cursor+Grid+GETFLDSTATE". The code sample from there is below.
>
>Before any saving from anywhere on the form (include functional keys, toolbar buttons, menu items from menu), run following code:
>
>
>&& áåðåì àêòèâíûé êîíòðîë
>oObj = thisform.ActiveControl
>if vartype(m.oObj) == "O" AND PEMSTATUS(m.oObj,"value",5)
>  && ïðîâåðÿåì ãðèä ëè îí, åñëè äà, èùåì òåêóùèé àêòèâíûé êîíòðîë
>  if upper(m.oObj.BaseClass) == "GRID"
>    nIndex = m.oObj.ActiveColumn
>    for i=1 to m.oObj.ColumnCount
>      if m.oObj.Columns(i).COlumnOrder = nIndex
>        nIndex = i
>        exit
>      endif
>    endfor
>    oObj = m.oObj.Columns(nIndex)
>    oObj = evaluate("m.oObj." + m.oObj.CurrentControl)
>  endif
>
>  && ïðîâåðÿåì ìåíÿëñÿ ëè êîíòðîë ïî ñðàâíåíèþ ñî çíà÷åíèåì ControlSource
>  if !(m.oObj.value==evaluate(m.oObj.ControlSource))
>    m.oObj.SetFocus && ýòîãî äîñòàòî÷íî ÷òîáû çàïèñàòü èçìåíåíèÿ â ControlSource
>  end if
>end if
>
>
>This is just a sample. To make it generic, you have to add checking for ActiveX controls, OLEBoundControl (you cannot compare field of General type) etc. I also did not tested the code - it was just a sample I took from my head. I used this approach many times to assure active control saved its value before firing the Valid event of the control.
>
>>Hi everybody,
>>
>>Here is a problem: for convenience in Data Entry I have certain F keys to perform actions. For instance, F9 key saves the data. First it checks validity of the data and if everything is fine, saves it. Otherwise it brings focus to the offending field. So, I type something in the textbox, then press F9 and it gives me the same error again, because field source hasn't yet updated with the value. What can I do? In FormValid always check against form controls and not the actual fields? Is there more convenient method?
>>
>>Ok, I have an idea: at the top of FormValid method check for ActiveControl, if it has value property set value=value.
>>
>>Do you think, this would work?
>>
>>Yep, it does work:
>>
>>if type('thisform.ActiveControl.value')<>'U' && Active control exists and has a value property
>>		   thisform.ActiveControl.value = thisform.ActiveControl.value
>>	endif
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform