Gene,
Here's a technique that might work for you. I didn't do it in a grid,
but I had a large number of fields that needed the same validation. The
problem, then, is a) avoid duplicating the code, and b) if you have to
correct a value to be able to put it in the right control.
In the Valid method (or LostFocus, if Valid won't work), do something
like this:
return oOrder.ValRange(this, this.value, 0, 6.0) && .T. or 0
where oOrder is a bizobj containing various validation methods.
------------------------------
procedure ValRange
parameters oControl, nVal, Lower, Upper
* Valid UDF for range variables
* oControl is a reference to the control being validated
if empty(nVal)
*-- Zero is legal
return .T.
endif
if between(Nval, Lower, Upper)
return .T.
else
oControl.value = -99 && or whatever value you want
wait window "Range: "+transform(Lower)+" to "
+transform(Upper) nowait
return 0
endif
endproc
---------------------------------
I don't do validation in the form, for uniformity if nothing else. I
used to do it in main program procedures, until I got more Politically
Correct and made it a Bizobj. <g>
Dan
On 11/08/13 03:40 PM, Gene Wirchenko wrote:
At 12:33 2013-11-07, Fred Taylor <[email protected]> wrote:
The values on the current row are referenced directly via the fields
in the
table/cursor. Don't use the objects in the columns to try and get the
values.
That does not work. That gives me the current row value in the
cursor. I do not want that. I want the control values in the grid,
because I want to check the current row before it gets used to update
the cursor.
If someone is updating a row and enters invalid data, I want to
catch that. Note that the issue is *specifically* for data requiring
the checking of more than one control to validate. (If it is just an
error in one control's data, I can catch that in the control's
.LostFocus().)
I am getting the feeling that I am going to have kludge this by
turning control validation off, quickly setting focus to each control in
the current row, then turning validation back on. And all this in a
beforerowcolchange. This looks as if it could be horribly ugly code.
Surely there is a simpler way? Please!
[snip]
Sincerely,
Gene Wirchenko
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.