Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing Focus on a form
Message
From
08/05/2002 06:28:39
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
07/05/2002 22:36:33
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00653825
Message ID:
00653891
Views:
34
Hi Mike

Do you realize this code fires every time the user presses any key? As records are added, its gonna get slower and slower.

I rarely only have one column, so I have a button for the user to click to begin the search. The button's click would be a simple way to get around SetFocus not being possible from a textbox's valid.

You might try moving the code to the pattern textbox's .LostFocus().

If the pattern is found
RETURN .T.
else
RETURN .F.
endif

That assumes the taborder has the cursor moving from the pattern to the grid.

Is there an index tag on upper(teacher)? Have you SET ORDER TO that index? If so, you could use SEEK instead of the first LOCATE.

UPPER(TRIM(MEM1)) is being checked on every record with the LOCATEs. So, create a MEM2 like this...

SET EXACT OFF
MEM2 = UPPER(TRIM(MEM1))
IF SEEK(MEM2)
RETURN .T.
ENDIF
LOCATE FOR MEM2 $ UPPER(TEACHER)
IF FOUND()
RETURN .T.
ENDIF
WAIT WINDOW "Name not found"
GO TOP
THISFORM.GRDHILIT1.SETFOCUS()


>I am attempting the create a "pattern" section in a search box above a grid.
>
>The grid has one column with a list of names.
>
>The pattern field asks the user to enter a few characters of the person's name then press ENTER. MEM1 is the name of the variable in the pattern field.
>
>The key press code for the pattern field is below:
>
>IF NKEYCODE = 13 && enter
> SET EXACT OFF
> LOCATE FOR UPPER(TEACHER) = UPPER(TRIM(MEM1))
> IF FOUND()
> THISFORM.GRDHILIT1.SETFOCUS()
> ELSE
> LOCATE FOR UPPER(TRIM(MEM1)) $ UPPER(TEACHER)
> IF FOUND()
> THISFORM.GRDHILIT1.SETFOCUS()
> ELSE
> WAIT WINDOW "Name not found"
> GO TOP
> THISFORM.GRDHILIT1.SETFOCUS()
> ENDIF
> ENDIF
>ENDIF
>
>This code provides a momentary focus on the Grid then it returns back to the pattern box.
>
>How do I get the focus to stay on the Grid?
>
>Mike Smith
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform