Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SEEK() not working as expected
Message
From
08/07/2000 17:16:45
 
 
To
08/07/2000 17:10:18
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00389870
Message ID:
00389872
Views:
18
>I have some code that generates a cursor on-the-fly to populate a grid. Two indices are created on this cursor.
>
>A separate text box provides incremental search of the grid. Some other code hooked into the .InteractiveChange of the text box steers the cursor record pointer.
>
Method LT2_CursorReordersDNRs builds and indexes the cursor:
>LOCAL ;
>	lnSelect
>
>lnSelect = SELECT(0)
>
>WAIT WINDOW NOWAIT "Building Indices..."
>
>* Open tables:
>USE (ALLTRIM(goApp.LT2_cLT1_DataRoot) + ALLTRIM(goApp.LT2_cYearName) + ;
>	"\Reorders") IN 0 SHARED
>
>SELECT ;
>	A.Reord_No, ;
>	A.CustName, ;
>	PADR(ALLTRIM(B.Sch_Name) + ", " + ;
>		ALLTRIM(B.Sch_City) + ", " + ;
>		ALLTRIM(B.Sch_Prov) + " " + ;
>		ALLTRIM(B.Sch_Phone), 70, " ") AS cSchool, ;
>	A.OrdrDate ;
>	FROM Reorders A ;
>		INNER JOIN Schools B ;
>		ON B.Sch_ID == A.Sch_ID ;
>	INTO CURSOR _SearchRD
>
>USE (DBF("_SearchRD")) ALIAS SearchRD IN 0 AGAIN
>
>SELECT SearchRD
>INDEX ON UPPER(CustName) TAG CustName
>INDEX ON UPPER(cSchool + CustName) TAG cSchool
>

A complete, utter SWAG, but try adding the ADDITIVE clause to the 2nd INDEX ON

>WAIT CLEAR
>
>SELECT (lnSelect)
>
>* Method LT2_IncrementalSearch performs the search:
>LPARAMETERS ;
>	tcSearchString
>
>LOCAL ;
>	lnSelect, ;
>	lcOldOnError, ;
>	llSoftSeekFailed, ;
>	lcSearchAlias
>
>lnSelect = SELECT(0)
>
>DO CASE
>CASE This.opgType.Value = 1
>	lcSearchAlias = "SearchSD"
>
>CASE This.opgType.Value = 2
>	lcSearchAlias = "SearchRD"
>
>CASE This.opgType.Value = 3
>	lcSearchAlias = "SearchGr"
>
>ENDCASE
>
>SELECT (lcSearchAlias)
>
>IF EMPTY(tcSearchString)
>	GO TOP IN (lcSearchAlias)
>
>ELSE
>	<b>IF SEEK(UPPER(tcSearchString), lcSearchAlias)</b>
>		* OK
>		
>	ELSE
>		* Not found, do a soft seek to get a close record:
>		lcOldOnError = ON("ERROR")
>		llSoftSeekFailed = .F.
>		
>		ON ERROR llSoftSeekFailed = .T.
>		
>		GO RECNO(0) IN (lcSearchAlias)
>		
>		IF llSoftSeekFailed
>			GO BOTTOM IN (lcSearchAlias)
>		
>		ENDIF
>	
>	ENDIF
>
>ENDIF
>
>* Pop the focus to the grid so the RecordMark shows properly:
>=This.grdSearch.SetFocus()
>=This.txtcSearchString.SetFocus()
>
>SELECT (lnSelect)
>
>The incremental search method supports searching in 3 cursors with a total of 5 index tags. Other controls ensure that the correct tag is active for the desired search.
>
>Everything works perfectly fine except for searches on the CUSTNAME tag of the SearchRD cursor. For that tag, any search string fails in the SEEK() call. That is, when running in the IncrementalSearch method, the SEEK() call returns .F. when it should return .T..
>
>Searches on its cSchool tag work perfectly. I can SUSPEND the code immediately before the SEEK() call, execute the same command in the Command window, and SEEK() works as expected.
>
>Searches in either of the other two cursors, on any of their supported tags, work fine as well.
>
>Both the SCHOOLS and REORDERS tables are FPDOS 2.6 free tables. I have copied the contents of the REORDERS tables out and rebuilt its indices from scratch.
>
>WAGs, anyone?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform