I'm further experimenting with the GRID and BROWSE control.
On validating data, is it possible to have more then one message for one column ?
I wrote this :
DEFINE BROWSE Browse_PRV
...
FIELDS {'LndID','PrvID','PrvNm' }
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () }
VALIDMESSAGES { , , 'Invalid name'}
WHEN { {||.F.} , {||.F.}, {||.T.} }
...
END BROWSE
FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm) .or. MemVar.PRV.PrvNm == "A"
RETURN .F.
ENDIF
RETURN .T.
If the name (3th column) is blanc or = 'A', I get the message 'Invalid name'. That works.
But how do I get this :
If the name is blanc, the message should be 'Blanc name'
If the name is 'A', the message shoud be 'A not allowed'
I tried a codeblock or a function in VALIDMESSAGES, but I failed.
I tried with 2 messageboxes in my function and set VALIDMESSAGES { , , }, but then I got my message and a default BROWSE message 'Invalid entry' too. I don't want 2 messages.
Is there any solution ?
Kind regards, Marc
The BROWSE control and VALIDMESSAGES
Moderator: Rathinagiri
Re: The BROWSE control and VALIDMESSAGES
a suggestion...
DEFINE BROWSE Browse_PRV
...
FIELDS {'LndID','PrvID','PrvNm' }
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () }
WHEN { {||.F.} , {||.F.}, {||.T.} }
...
END BROWSE
FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm)
MsgInfo('Blanc name')
RETURN .F.
ENDIF
IF MemVar.PRV.PrvNm == "A"
MsgInfo('A not allowed')
RETURN .F.
ENDIF
RETURN .T.
DEFINE BROWSE Browse_PRV
...
FIELDS {'LndID','PrvID','PrvNm' }
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () }
WHEN { {||.F.} , {||.F.}, {||.T.} }
...
END BROWSE
FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm)
MsgInfo('Blanc name')
RETURN .F.
ENDIF
IF MemVar.PRV.PrvNm == "A"
MsgInfo('A not allowed')
RETURN .F.
ENDIF
RETURN .T.
Re: The BROWSE control and VALIDMESSAGES
Thank you for your suggestions, but I did try already the MsgInfo in my function and set VALIDMESSAGES { , , }
Then I got the correct error message followed by the standard BROWSE message 'Invalid entry'. I don't want 2 messages.
Do you have other suggestions ?
Kind regards, Marc
Then I got the correct error message followed by the standard BROWSE message 'Invalid entry'. I don't want 2 messages.
Do you have other suggestions ?
Kind regards, Marc
Re: The BROWSE control and VALIDMESSAGES
To pctoledo, In attachment a movie InvalidEntry to demonstrate that I then get 2 messages. I only want my own message.
But it was a nice suggestion.
Kind regards, Marc
But it was a nice suggestion.
Kind regards, Marc
- Attachments
-
- InvalidEntry.zip
- (560.9 KiB) Downloaded 202 times
Re: The BROWSE control and VALIDMESSAGES
other suggestion:
Code: Select all
#include "hmg.ch"
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 510 ;
TITLE 'Test Browse' ;
MAIN
USE PRV NEW
INDEX ON LNDID TO PRV
@ 10,10 BROWSE Browse_PRV ;
WIDTH 770 ;
HEIGHT 440 ;
HEADERS {'LndID','PrvID','PrvNm' } ;
WIDTHS {100,100,220} ;
WORKAREA PRV ;
FIELDS {'LndID','PrvID','PrvNm' } ;
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () } } ;
WHEN { {||.F.} , {||.F.}, {||.T.} } ;
EDIT
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
_HMG_SYSDATA [ 136 ][11] := 'Invalid entry'
Return
FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm)
_HMG_SYSDATA [ 136 ][11] := 'Blanc name'
RETURN .F.
ENDIF
IF MemVar.PRV.PrvNm == "A"
_HMG_SYSDATA [ 136 ][11] := 'A not allowed'
RETURN .F.
ENDIF
RETURN .T.
Re: The BROWSE control and VALIDMESSAGES
Hi pctoledo,
I am pleasantly surprised , it works perfectly. Thank you very much for your solution.
Kind regards, Marc
I am pleasantly surprised , it works perfectly. Thank you very much for your solution.
Kind regards, Marc