INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Results not shown in Grid inside a Form

Results not shown in Grid inside a Form

(OP)
Dear collegues:

Once more I am here to ask your help for a single question:



In the figure above I wish, after typing the text FAR in the TextBox, all the items from the table TACO.DBF beginning with "FAR" to be shown (see 1).
But the result (see 2, -- "Result") shows nothing... in spite of the fact that TEMPTACO.DBF is populated with the desired rows after the user press <enter> (see figure bellow) !



Note that when I execute the form it shows the result I would like to have in the session immediately before (Content from TEMPTACO.DBF) !


I have:


Form, DataEnvironment is TEMPTACO.DBF


Form, KeyPress event is:

CODE

IF nKeyCode=13 AND nShiftAltCtrl=0 
	Parte=ALLTRIM(ThisForm.QualTaco.Value)
	LenParte=LEN(Parte)

	IF LenParte=0
		thisform.Release
	ENDIF

	
    SELECT TACODESCR AS WTACODESCR, TACOCALOR AS WTACOCALOR;
 	FROM TACO ;
 	WHERE UPPER(Parte) = UPPER(LEFT(TACO.TACODESCR,LenParte)) ;
 	INTO TABLE TEMPTACO

	thisform.Grid1.Refresh
ENDIF 

Grid1, DblClick:

CODE

thisform.Release 

Thank you,
SitesMasstec

RE: Results not shown in Grid inside a Form

>INTO TABLE TEMPTACO

This is what you should never do with a table you display in a grid. You recreate the DBF and though that means after the query everything is back, the grid "notices" this. The moment the DBF is destroyed before it is rebuild is the moment your grid becomes blank.

Do this instead:

CODE

ZAP IN TEMPTACO
INSERT INTO TEMPTACO ;
SELECT TACODESCR AS WTACODESCR, TACOCALOR AS WTACOCALOR;
 	FROM TACO ;
 	WHERE UPPER(Parte) = UPPER(LEFT(TACO.TACODESCR,LenParte)) 

There are some prerequisites for this:
1. TEMPTACO.DBF already exists
2. You have exclusive access to it.

A much better approach would NOT gnerate a permanent DBF file but a cursor. Also that will need to be kept for the grid to work, but everything you only want temporary does not need to go to hard drive.

Bye, Olaf.


RE: Results not shown in Grid inside a Form

(OP)
Good, Olaf, I abandoned the hard drive here, as you advised:

thisform.Grid1.RecordSource = ""
SELECT TACODESCR, TACOCALOR FROM TACO ;
WHERE UPPER(Parte) = UPPER(LEFT(TACO.TACODESCR,LenParte)) ;
INTO CURSOR TEMPTACO
thisform.Grid1.RecordSource = "TEMPTACO"

No more temporary table, but cursor instead.

And it is working fine now. Thank you.


Thank you,
SitesMasstec

RE: Results not shown in Grid inside a Form

Also with a cursor it's advisable to use the ZAP and refill strategy.

In form init prepare the empty cursor:

CODE

SELECT TACODESCR, TACOCALOR FROM TACO WHERE .F. INTO CURSOR crsTEMPTACO READWRITE 

In your keypress:

CODE

IF nKeyCode=13 AND nShiftAltCtrl=0 
	Parte=ALLTRIM(ThisForm.QualTaco.Value)
	LenParte=LEN(Parte)

	IF LenParte=0
		thisform.Release
	ENDIF

ZAP IN crsTEMPTACO
Insert Into crsTEMPTACO;
SELECT TACODESCR, TACOCALOR FROM TACO ;
WHERE UPPER(Parte) = UPPER(LEFT(TACO.TACODESCR,LenParte))

	thisform.Grid1.Refresh
ENDIF 

When working this way the cursor stays, the ZSAP only empties it. There is no need to temporary unbind the RecordSource and that only is a half solution anyway for several reasons too long to state right now.

Bye, Olaf.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close