xsharp.eu • Validating SLE entry
Page 1 of 1

Validating SLE entry

Posted: Mon Jul 29, 2019 1:47 am
by Anonymous
I've crawled all over the old NG, seen this mentioned quite often, but no real successes it seems.

I have a SLE (I've tried RightSLE and SearchSLE also) on my screen. It's called PO Number. What I need to achieve is as the user is typing in that field AND/OR after the cursor leaves the field (tried EditFocusChange unsuccessfully) it searches to see if that particular PO number is already in the system. If so, I need a warning box to popup telling the user it already exists, and give them 3 options - View Other record, Continue with it or cancel. This window I have already built. It's the validating that I can't seem to get.

Any ideas please?

Validating SLE entry

Posted: Mon Jul 29, 2019 3:26 am
by wriedmann
Hi Jeff,
the EditFocusChange() event works when the focus on a edit control is changed, and it definitely works - I'm using it massively. But this event often is called twice, first for the control that is leaved, and then for the control that is entered.
To catch changes in an edit control itself, you need the EditCHange() event, and access the value of the control through the TextValue access.
But what you should not do in both events: do anything that shifts the focus, for example opening a messagebox.
It is much better to use an error display control.
Wolfgang

Validating SLE entry

Posted: Mon Jul 29, 2019 3:40 am
by BiggyRat
Hmmmm thanks Wolfgang, that might go a fair way to explaining what's going on. Thanks very much :)

This what I had been experimenting with...

if self:oSFJobInfo_DETAIL:oDCPONumber:ValueChanged
oDb := DETAILS{}
oDb:SetOrder("PONUMBER", "DETAILS")
oDb:GoTop()
oDb:OrderScope( TOPSCOPE, AllTrim(self:oSFJobInfo_DETAIL:oDCPONumber:CurrentText))
oDb:OrderScope( BOTTOMSCOPE, AllTrim(self:oSFJobInfo_DETAIL:oDCPONumber:CurrentText))

IF oDb:OrderKeyCount("PONUMBER", "DETAILS") > 1
DuplicateRef{}:Show(SHOWCENTERED) <--a Dialog Window I created.3 buttons as described in my first post. It does absolutely NOTHING except display, and the Close button has EndDialog in it.at this point

endif

oDb:OrderBottomScope
oDb:OrderTopScope
oDb:GoTop()
oDb:SetOrder("JOBNUMBER", "DETAILS")
oDb:GoTop()
self:oSFJobInfo_DETAIL:oDCPONumber:ValueChanged := FALSE
endif

It works OK, but kills the relationship and indexes between Client.dbf and Details.dbf...It's in the Update Button though, not really the desired outcome, but will do if need be.

Jeff

Validating SLE entry

Posted: Mon Jul 29, 2019 7:07 am
by lumberjack
Hi Jeff,
BiggyRat wrote:I have a SLE (I've tried RightSLE and SearchSLE also) on my screen. It's called PO Number. What I need to achieve is as the user is typing in that field AND/OR after the cursor leaves the field (tried EditFocusChange unsuccessfully) it searches to see if that particular PO number is already in the system. If so, I need a warning box to popup telling the user it already exists, and give them 3 options - View Other record, Continue with it or cancel. This window I have already built. It's the validating that I can't seem to get.
Ok you will probably have to play with this a bit, as I have my EditFocusChange event on the Control level, but the principle is the same:

Code: Select all

METHOD FocusChange( oFCE ) CLASS ODI_SLE
	IF IsMethod( SELF:Owner, #FocusChangeEditControl )
		SELF:Owner:FocusChangeEditControl( SELF, oFCE:GotFocus )
	ENDIF
RETURN NIL
I think the magic trick you after is the FocusChange() method, not EditFocusChange() and oFCE:GotFocus property.

HTH,

Validating SLE entry

Posted: Tue Jul 30, 2019 12:38 am
by BiggyRat
Excellent. Thank you Johan, I'll give that a try.