>*-------------------------------------------------------------------------- >* -- updated:rmm:10/01/01 >* -- && Updated:NN: 06/03/02 - added GroupBy clause >* -- Validates the code keyed in, if incorrect, then pop up list will >* -- display the correct codes >*-------------------------------------------------------------------------- >lparameters tcTable, tcIndex, tcFldVal, tcSrchFld, tcCode, tcDesc, ; > tcControlSrc, tcListMsg, tcWhr, tcGroupBy >*:lnCounter added to only display alert message if invalid code selected more than once > >if vartype(m.tcWhr)<>"C" > tcWhr = "" >endif > >if vartype(m.tcGroupBy)<>"C" > tcGroupBy = "" >endif > >local lnCounter, lcFilt >lnCounter=0 >*:New Code to ensure accurate validation - create a loop for this code >*:until a valid entry is selected >do while .t. >*:REV 12/27/01 SBB - need to add other condition when tcWhr is not empty > if !empty(m.tcWhr) >*:REV 2/13/02 SBB IMPORTANT NOTE FOR USING THIS METHOD >*:The where clause being passed is used for the locate below and >*:for the SQL statement if the value is not found. Note that the "Where" of the >*:clause is not needed below but is needed in the SQL Statement. Therefore, the >*:"Where" term is also being passed as part of the lcWhr parameter >*:For the case below, I am stripping out the first 6 chars ("Where ") to use >*:the parameter as a filter condition. If that fails, note that the entire >*:lcWhr value is used in the SQL as it is required. Therefore "where " must be passed >*:as part of the value for this method to work properly. > > lcFilt=substr(m.tcWhr,7) > select (m.tcTable) > locate for &tcSrchFld. = m.tcFldVal and &lcFilt > else > select (m.tcTable) > locate for &tcSrchFld. = m.tcFldVal > endif > if not found() >*:Only display this alert on the second incorrect entry > lnCounter=m.lnCounter+1 > > if not empty(m.tcFldVal) && Some code was selected > > if m.lnCounter>1 > do alert with 'Not a valid code. Please select from the list' > endif > > select &tcCode.+' -'+&tcDesc. as text, ; > &tcCode. as CodeVal, &tcDesc. as Description ; > from (m.tcTable) ; > &tcWhr. ; > &tcGroupBy. ; > order by 3,2 ; > into cursor PopCursor > > do form LookupPop with m.tcControlSrc, m.tcListMsg, alltrim(m.tcFldVal) to tcFldVal >*:Check the value that was selected >*!* if not empty(m.tcControlSrc) >*!* tcFldVal=evaluate(m.tcControlSrc) > >*:Pass the value selected to the lcFld and check again > select PopCursor > use > else && empty code > exit > endif > else > exit > endif >enddo >return m.tcFldVal>
>if this.DoValid > if thisform.CancelValidation() > return > endif > if not empty(this.value) > thisform.ValidateCode('deedtype','deedtype', this.value, ; > 'deedtype.code','code','fullname', ; > 'BldMstr.DeedType', ; > 'Pop up List for Deed Type', ; > iif(thisform.LocState='MA','where inlist(code,"FD","LC"," ")', ; > 'where not inlist(code,"FD","LC")')) > this.value = BldMstr.DeedType > endif >endif>