Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nothing Showing Up In Grid!

Status
Not open for further replies.

VFP2013

Programmer
Oct 19, 2013
20
US
I am currently working with a Dry Cleaning software program. In the screen where a user checks the customer out and receives payment. Here is the code:
Code:
**INIT**
thisform.label1.Caption=ALLTRIM(Name)+" # "+ALLTRIM(PPhone)
USE tempo SHARED
nRecs=RECCOUNT()
FOR x=1 TO nRecs && I know there are better ways, like using SCAN, but I find this easier for me.
WAIT WINDOW "Parsing Record "+TRANSFORM(x)+" of "+TRANSFORM(nRecs) TIMEOUT .2
USE tempo shared
GOTO x
IF tempo.custno=nCustno AND ALLTRIM(UPPER(tempo.hit))!="X" && "X" defines that an order is already checked out
invno=tempo.invcno
stat=tempo.stat
custno=tempo.custno
totla=tempo.total
USE temptempo
APPEND BLANK
GO bottom
replace temptempo.invcno WITH invno,;
temptempo.stat WITH stat,;
temptempo.custno WITH custno,;
temptempo.total WITH totla
ENDIF
ENDFOR
thisform.grid1.RecordSourceType= 0
thisform.grid1.RecordSource="temptempo.dbf"

Nothing is showing up in my grid. I've checked by debugging it with a "CHANGE" Command into the command window after the code has been ran. The table contains the records that meet the criteria, but it is not loading into the table. Please help! and Thanks in advance!
 
Recordsource has to be set to the alias name only, no .dbf and Recordsourcetype finally has to be set back to 1.

Besides that:
you open tempo again and again in each loop iteration, why?
you go bottom after appenb blank, why? Append blank puts the record pointer to the new record itself.
you could insert instead of append blank+replace.

Bye, Olaf.

PS: you copy some records of tempo to temptempo, you can do this with a query:

Code:
**INIT**
thisform.label1.Caption=ALLTRIM(Name)+" # "+ALLTRIM(PPhone)
Select invcno,stat,custno,total FROM tempo WHERE custno=nCustno AND ALLTRIM(UPPER(hit))!="X" INTO CURSOR temptempo READWRITE
thisform.grid1.RecordSource ="temptempo"
thisform.grid1.RecordSourceType = 1

Which version of VFP are you using?
 
That code is curious.
I think, if I was forced to use it at all, I would be tempted to make sure that
temptempo was closed at some point, and opened in a new work area for the grid.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
As Olaf points out, you should never have more than one USE command per table. Once a table is open, it does not need to be opened again. If you need to access it you SELECT it.

I'd replace the whole thing with something like:

Code:
Insert Into TempTempo ;
   (invcno,stat,custno,total) ;
   Select invcno,stat,custno,total FROM tempo WHERE custno=nCustno AND ALLTRIM(UPPER(hit))!="X"

No need for any looping at all.
 
Olaf, I've tried setting recordsourcetype to 1 and removing the .dbf from recordsource. still nothing

Thanks!
Ty
Head Developer
Shft Software
 
That's because you're opening and closing tables. The grid deconstructs.
 
Which version of VFP are you using?
Which Init are we talking about, Form.init, grid.int?

Even if, as dan says, the grid deconstructs, once you have the temptempo table or cursor the recordsourcetype=1 and recordsource="temptempo" will reconstruct grid columns, it shouldn't be empty, unless you have 0 records.

What does MESSAGEBOX(TRANSFORM(RECCOUNT("temptempo"))) show right after the loop or query?

Bye, Olaf.
 
Another problem with your code:

[tt]WAIT WINDOW "Parsing Record "+TRANSFORM(x)+" of "+TRANSFORM(nRecs) TIMEOUT .2[/tt]

If your table is at all large, this could seriously slow down your processing. This would be much better:

[tt]WAIT WINDOW "Parsing Record "+TRANSFORM(x)+" of "+TRANSFORM(nRecs) NOWAIT[/tt]

But even that will be much slower than not showing a WAIT message at all.

A good compromise would be something like this:

[tt]IF MOD(RECNO() / 100) = 0
WAIT WINDOW etc.
ENDIF[/tt]

Of course, if the table only has a few records (say, less than a few hundred), it won't make so much difference.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Here do this:

Code:
**INIT**
thisform.label1.Caption=ALLTRIM(Name)+" # "+ALLTRIM(PPhone)
if not used('Tempo')
   use Tempo in 0 Shared
endif

WAIT WINDOW "Feting customer records.  Please wait.. " NOWAIT

thisform.grid1.RecordSource = ""
SELECT INVNO,STAT,CUSTNO,TOTLA FROM TEMPO WHERE CUSTNO = nCustNo and upper(Alltrim(Tempo.Hit)) <> 'X' order by InvNo into cursor curOpenRecs

thisform.grid1.RecordSource="curOpenRecs" 
thisform.grid1.Refresh()
Wait Clear 

** In the Unload of the form ** 

if used('curOpenRecs')
  use in select('curOpenRecs')
endif

Ez Logic
Michigan
 
Nice code, Ez. I'd suggest one very small improvement: In the Unload, instead of this:

Code:
if used('curOpenRecs')
  use in select('curOpenRecs')
endif

do this:

Code:
use in select('curOpenRecs')

The effect is the same, but it's always nice to save a couple of lines of code.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike, you're right about that last code :)



Ez Logic
Michigan
 
Olaf, MESSAGEBOX(TRANSFORM(RECCOUNT("temptempo"))) returns "3". EZlogic, your code is working most of the way, there is just still nothing in the table. But the table is showing up now (the columns) no records though.

Thanks!
Ty
Head Developer
Shft Software
 
GO TOP to see the records.

Bye, Olaf.

PS: If you'd do the query solutions, you'd be at TOP of the data anyway. If you're at the bottom you see an empty grid, though.

Bye, Olaf.
 
GO TOP didn't work. There are no records showing. Also, using a cursor is not a good solution for this form Because, the user has to be able to place data directly in the field of different records, then the table is parsed for records where temptempo.hit=="X"

Thanks!
Ty
Head Developer
Shft Software
 
VFP2013,
The only way i see my work won't work if There aren't any records in the table for the customer number = nCustNO and Hit <> 'X' (or if nCustno is there, then all must have been X basically)

Ez Logic
Michigan
 
Well, as I've said before. I can check temptempo with a CHANGE statement and I can see the records in it. It's just not showing on the grid. A sincere thanks to all of you though!

Thanks!
Ty
Head Developer
Shft Software
 
Guys, I got an older version of the whole form from a past version of the application that I decompiled with Refox X. Everything is working as planned now. Thanks!

Thanks!
Ty
Head Developer
Shft Software
 
Well, did ou GO TOP in temptempo?

You last statementment reflects your discontent with our help, as nothing works for you and you solved it on your own, but it's really hard to help you, if you don't answer questions.
Anyway, good it's solved. If you'd share the solution it would be good. Otherwise I might tend to report this thread for deletion, as it's very unfruitful.

>using a cursor is not a good solution for this form Because, the user has to be able to place data directly in the field of different records, then the table is parsed for records where temptempo.hit=="X"
That's possible with a cursor created READWRITE.

And for the third time asked: Which version of VFP are you using? READWRITE and INSERT INTO ... SELECT FROM doesn't work in all VFP versions. Many things need to be considered, but if you don't share you can't expect working help. If you're using a legacy version, there's forum forum182, the outset for helping you with legacy code differs ery muuch from the help you receive here, but even in the range of VFP versions the language and capabiliites vary very much.

Bye, Olaf.


 
Olaf, My sincerest apologies for the way my last post may have been presented. Please know that I was not discontent with the solutions in any way, I wanted to take everybody's advice to better my code, but I always knew that my decompiling route was an option. I just thought It'd be a good idea to get some professional opinions. I really do appreciate each and every solution you guys have provided, but I do have a deadline to meet and it just seemed like the quickest route. As for my code that fixed it, I will be posting it tomorrow, as I am on a different machine right now. But thanks again, Olaf. I look forward to collaborating, helping, and prospering by/with you in the future. Thanks!

Thanks!
Ty
Head Developer
Shft Software
 
Hello Ty,

thanks for clearing that matter up! That's very fine of you and I understand your timing problems.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top