Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Problem
Message
 
To
21/01/2003 11:53:37
Marcus Hüneke
Heidelberger Druckmaschinen
Wiesloch, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00743708
Message ID:
00744612
Views:
8
Hi Marcus,

The reason is simple and it has nothing to do with the changing of the RecordSource.

You have form.GridRefreshing property.
Initially it is set to .F.

In the button.Click() method where you change the grid recordsource, you also set
thisform.GridRefreshing = .t.
But in the grid.BeforeRowColChange() event you have the following code:
IF PEMstatus(thisform,"GridRefreshing",5) and thisform.gridrefreshing
	NODEFAULT
	RETURN
ENDIF
Then the code inside IF statement fires, and NODEFAULT prevents your grid from moving to the found record.

BTW the code in grid events like .BeforeRowColChange() and .AfterRowColChange() may be tricky to trace, as on tracing the focus goes to the Debug window and if you return to the grid, then .BeforeRowColChange() or .AfterRowColChange() fire again and again making things screwed up. In addition your KeyPress() method code depends on the interval between keystrokes which adds up the complexity into debugging and does not speed up the debugging process. :)

So, in this particular case I used good old SET DOHISTORY ON command in KeyPress() method, then compared the output results and immediately found the culprit. Here is the output:
*** Code executed in KeyPress event
*** Before clicking on "Suchen" button
IF SECONDS() - searchtime < 1
searchname = UPPER(CHR(nkeyCode))
ENDIF
SELECT tabelle
LOCATE for LEFT(UPPER(tabelle.matnr),LEN(searchname))= searchname
IF NOT FOUND()
WITH thisform.grid1
.Refresh()
IF PEMstatus(thisform,"GridRefreshing",5) and thisform.gridrefreshing
.setfocus()
ENDWITH
searchtime = SECONDS()
NODEFAULT
*****
***Code executed in KeyPress event
***After clicking on "Suchen" button that changes the RecordSource

IF SECONDS() - searchtime < 1
searchname = UPPER(CHR(nkeyCode))
ENDIF
SELECT tabelle
LOCATE for LEFT(UPPER(tabelle.matnr),LEN(searchname))= searchname
IF NOT FOUND()
WITH thisform.grid1
.Refresh()
IF PEMstatus(thisform,"GridRefreshing",5) and thisform.gridrefreshing

**********
NODEFAULT
RETURN
**********

.setfocus()
ENDWITH
searchtime = SECONDS()
NODEFAULT
>Thank you for your quick answer.
>I've tried everything. My grid uses an alias (if I use "table" as RecordSourcetype my incremental search doesn't work).
>I have two tables, one with the whole data and one with the data out of a SQL query. If I change the recordsource from one to the other table my grid looks fine. But the keypressed event out of the grid's text segment doesn't work any more.
>I've tried all "workarounds" out of the FAQ document, but nothing works (even the BeforeRowColChange "trick".
>My last try was (
>
>thisform.gridrefreshing =.T.
>WITH thisform.grid1
> .RecordSource = ""
>ENDWITH
>sql_stat = "select * from tabelle where substr(upper(matnr),1,len(alltrim(thisform.text1.value)))" +;
>"= alltrim(upper(thisform.text1.value)) into table c:\dummyhier"
>&sql_stat
>SELE dummyhier
>WITH thisform.grid1
> .RecordSource = "dummyhier"
>ENDWITH
>thisform.grid1.refresh
>thisform.gridrefreshing = .F.
>
>
>***************************************************************
>the grids "BeforeRowColChange" contains
>IF PEMstatus(thisform,"GridRefreshing",5) and thisform.gridrefreshing
> NODEFAULT
> RETURN
>ENDIF
>
>// Marcus
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform