*---------------------- Location Section ------------------------ * Library: aFormsSearch.vcx * Class: FrmSearchParent * Method: Search() *----------------------- Usage Section -------------------------- *) Description: *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 01/05/2005 - NN * MODIFIED *-- CHANGE - NN - May 22, 2005 *--------------------------------------------------------------------------------------------- #undef CRLF #define CRLF chr(13) + chr(10) private plStop plStop = .f. with thisform .WaitMode(.t.) if .grdSearch.lShowSortingArrows .grdSearch.ClearHeaderPictures() endif .oBizObj.EmptySearchResult() local loWaitMessage, loMessage, lcMessage, loThermo lcMessage = "" llReturn = .ValidateUserInput() if m.llReturn loWaitMessage = createobject("cWaitMessage", "Getting data...") loMessage = createobject("cMessage", "Getting data...") loThermo = createobject("cusSQLThermo") .ReallyLockScreen (.t.) if .oSearchCollection.requery() or .oBizObj.lNoRecordsSelected .ReallyLockScreen (.f.) if not m.plStop .nRecords = .oBizObj.nRecords loMessage.show("Your search produced " + transform(.nRecords) + " records. ") wait clear lcMessage = 'Records Found: ' + NumberCommas(.nRecords) if not m.plStop and .nRecords > 0 and reccount('c_Search') = 0 && Too many records if YesNo("Your search produced " + transform(.nRecords) + " records. " + CRLF + ; "It may take some time to display them." + CRLF + "Do you still want to proceed?") loWaitMessage.show ("Creating the final result... Please wait or press ESC to cancel") .ReallyLockScreen (.t.) .nRecords = .oBizObj.CreateFinalResult() .ReallyLockScreen (.f.) else lcMessage = "Too many records to display " + "(" + ; NumberCommas(.nRecords) + ")" endif endif release loThermo if .nRecords = 0 or reccount(.grdSearch.recordsource) = 0 *------------------------------------ *--- No records found. Disable the *--- grid and the Select button *------------------------------------ store .f. to .cmdSelect.enabled, .grdSearch.enabled if not m.plStop and .nRecords = 0 if not .oBizObj.lError && otherwise the error was already reported MsgSvc('ErrorMsgDisplayValueOfVariable',.cNoRecordsMsg) endif lcMessage = 'No records to display' endif .SetFocusToFirst(thisform) else *--------------------------------------- *--- Records found. Enable the grid *--- and the Select button. Set focus *--- to the grid *--------------------------------------- goto top store .t. to .cmdSelect.enabled, .cmdCancel.enabled, .grdSearch.enabled .grdSearch.setfocus() lcMessage = 'Records Found: ' + NumberCommas(.nRecords) .grdSearch.highlightstyle = 2 .cmdCancel.caption = "\<Clear" && It's now clear, not cancel endif .ReallyLockScreen (.f.) endif else ** Something went wrong endif if m.plStop .ReallyLockScreen (.f.) =ErrorMsg ('Search was cancelled!') lcMessage = 'Search was cancelled ' endif endif .WaitMode(.f.) if m.plStop && Search was cancelled, clear the results .oBizObj.EmptySearchResult() endif .grdSearch.refresh() release loMessage, loWaitMessage .ChangeFormTitle(m.lcMessage) set message to .caption .cls() endwith plStop = .f. return m.llReturnI'll send the SearchBiz object code in a separate message.