on error do CurErrHandler with error() && Custom Error Handler to handle Numerical Overflow Error scan lnCount=m.lnCount+1 if m.plHalt if messagebox('Do you want to stop appending process?',36,'Stop Append')=6 exit else plHalt = .f. endif endif if m.pnNumberOfProblems > 0.1* m.lnReccount && More than 10% of total record number are problematic =messagebox('File was not appended, because number of errors exceed 10% of total number of records...' + ; chr(13)+'Correct the problem and try again',48,'Too many errors') plHalt = .t. exit endif ** Update status message if mod(m.lnCount,100) = 0 set message to 'Record # '+transform(m.lnCount)+m.lcMsgTail endif ** Update thermometer if mod(m.lnCount,m.lnUpdateNumber) = 0 loTherm.update(m.lnCount) endif scatter memvar memo if m.llNoRecNum RecNum=m.lnCount endif do case case m.tcOperation=upper('ParcelProc') source='P' SaleSrce='P' ccode=oJC.ccode Town=oJC.Town if !empty(oJC.Fy) Fy=oJC.Fy TaxYear=iif(!empty(oJC.TaxYear),oJC.TaxYear, oJC.Fy) endif RelAge='N' && Set Relative Age 'N' (new), ADC then will set appropriate flag case m.tcOperation =="" && empty tcOperation if type('SourceFile.Source')<>'C' if vartype(m.Seller1)='C' source=iif(empty(m.Seller1),'M','S') SaleSrce=m.Source else source='S' SaleSrce=m.Source endif endif otherwise && Take as it is endcase select DestFile append blank gather memvar memo endscan oJC.StepRecCount = reccount('DestFile') && Save reccount use in select('SourceFile') use in select('DestFile') if m.lcStatusBar='OFF' set status bar off endif lnElapsed = seconds() - m.lnStartTime && # seconds elapsed wait window nowait "Append took "+ ltrim(transform(m.lnElapsed, '9999999.99')) + " seconds." release loTherm on escape &lcPrevOnEsc if m.lcPrevEscape="OFF" set escape off endif endif if !m.plHalt if OpenTble(m.lcNewBldMstr+'_B',m.lcNewBldMstrName+'_B','exclusive') if !GenerateIndexes(m.tcBldMstr,m.lcNewBldMstrName+'_B') =messagebox("Indexes were not generated because you don't have the correct structure of "+m.tcBldMstr+"!"+chr(13)+ ; "Generate new "+m.tcBldMstr+" first",48,"Error") =CloseTbls(m.ltBldMstr, m.ltValLog, m.lcSetDB) select (m.lnOldArea) if m.lcOldSafety='ON' set safety on && Restore Safety settings endif return .f. endif else =CloseTbls(m.ltBldMstr,m.ltValLog, m.lcSetDB) select (m.lnOldArea) if m.lcOldSafety='ON' set safety on && Restore Safety settings endif return .f. endif * -- Now set this new buildmaster table to be oJC.curTable oJC.curTable=m.lcNewBldMstr+'_B' && Store the path and name of the new created BuildMaster table else wait window nowait 'User interrupted appending process...' endif use in select(m.lcNewBldMstrName+'B') set database to (m.lcNewBldMstr) close database set message to '' *--- Return to the work area you were in before coming here. select (m.lnOldArea) if m.lcOldSafety='on' set safety on endif if !empty(m.lcSetDB) set database to (m.lcSetDB) endif on error &lcOldError && Restore previous Error Handler return !m.plHalt ************************************************ function CloseTbls(tcBldMstr, tcValLog, tcDBC) use in select('DataDict') use in select('IndxDict') use in select(m.lcNewBldMstrName+'_B') use in select(m.lcNewBldMstrName+'_V') *--- Erase temp files erase (m.tcBldMstr+'.*') erase (m.tcValLog+'.*') close database if !empty(m.tcDBC) set database to (m.tcDBC) endif return *************************** function CurErrHandler lparameter tnErrorNum if not 'vfpevent.fll' $ lower(set('library')) set library to vfpEvent.fll additive endif if m.tnErrorNum = 39 && Numeric overflow local lnFields, lnI, lcAlias, lnRecord, lnResult lcAlias = alias() lnFields = afields(laFields,m.lcAlias) && assuming the table is opened lnRecord = recno(m.lcAlias) for lnI=1 to m.lnFields if inlist(laFields[m.lnI,2],'N','I','B','Y','F') and ; "*" $ transform(evaluate(m.lcAlias+"."+laFields[m.lnI,1])) && This is a field, which gave an error lnResult = EventMBox('Field '+ laFields[m.lnI,1]+" would be blanked because of numeric overflow "+ ; chr(13)+"on the record "+transform(m.lnRecord)+" in file "+dbf(m.lcAlias)+ ; chr(13)+"Do you want to continue the appending process?", ; MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON1, ; "Error is encountered!", ; "&Proceed", ; "&Stop", "") blank field (laFields[m.lnI,1]) pnNumberOfProblems = m.pnNumberOfProblems + 1 && Increment number of problems if m.lnResult = IDNO && Stop plHalt = .t. && Stop the process endif endif next return else error m.tnErrorNum && produce an error and handle it by normal error Handler endif>Hye,