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!

Grid Refresh

Status
Not open for further replies.

Shanachie

Programmer
Jun 18, 2000
92
US
I've got a grid that presents a list of customers for the user to choose from. The user may want to see the list in different orders depending on circumstances (e.g., last activity date, account rep name, main contact name, etc.). I've got buttons on the form to resort the table. (The grid references the table through an alias.) When a sort button is clicked, a SQL select command sorts the table into a temp dbf, deletes the original table, then selects the temp back into the original table. This is all working right except that the grid is blank when done. Refresh()ing the grid doesn't fix it. Data session shows that the alias is correct and selected. I suspect that the problem has to do with deleting the table. How do I get the grid to show the result? Would it be better to DELETE ALL, PACK, and APPEND?

Any suggestions?


TIA,
Shanachie

PS Thanks to all for the responses. You've earned my &quot;ever-asking&quot; gratitude. <g>
[sig][/sig]
 
Hi, Shanachie!

Grid goes blank because table close. To avoid that, use following:

Grid.RecordSource = &quot;&quot;
&& refresh alias
...........
Grid.RecordSource = &quot;MyAlias&quot;
&& restore control sources of columns if they're in other order than order of fields in alais
Grid.Column1.ControlSource = &quot;MyAlias.MyField1&quot;
...

Finally, why requery for sorting? You may use INDEX command to index result cursor into temporary CDX file by field you need. This have a lot of benefits: you work on this locally, and you do not need to query data again (no network traffic during that). And you can do this from grid's header click event.
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Changing the .RecordSource to &quot;&quot; and back again after I made a new source didn't work for me in a somewhat similar instance to Shanachie's. But my grid's source is a SQL.

I want to use a Listbox of values that when one is chosen thru InteractiveChange (though I'll probably move the code to a commandbutton) will requery the grid's SQL to ..WHERE MyField = the value of the list. To get the grid to show at all after this I had to RemoveObject and AddObject it back resetting all non default properties since it isn't classed. Man grids are weird. Perhpas I should just use another list, 2 columns, instead of a grid where I can simply .Requery() it. But I really like the 'look' of grids. &quot;Bad.&quot; &quot;Bad grid.&quot; [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
ICQ VFP ActiveList #73897253[/sig]
 
John, once upone the time I thought it will be better to create grid class and include some tricks and helpful functionality to help build forms with grids quickly, easy and without mess you mentioned. Now I have good class with all I want and never have reason to say that grid is 'Bad'. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
so you simply remove and add it back? [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
ICQ VFP ActiveList #73897253[/sig]
 
Yep. And grid automatically does job on restoring of control sources (Using RecordSource_Assign). As well as it checks if grid rebuilt (you know, it happens often in VFP), and replaces controls and headers by custom classes. Now I never write code inside events of controls or headers, all mapped to grid methods that is easy to program because do not need to write the same code line in each grid column. There are many other features, like outlook-like headers ('...' at the end of caption of it do not fit in header), sorting with nice sorting indicator etc. I cannot describe all here. If you're interested, I can post sample code or even snapshot of how my grid looks like when sorted ;) [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Ya sounds good. Me and Robert talked about getting a good program to capture screen activity and sound like MS used in some help videos. I think Camtasia is the best out there but I'd like to find a good free one. Anyways I was thinking it would be nice to see how yours functions in action. [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
ICQ VFP ActiveList #73897253[/sig]
 
Anyways I was thinking it would be nice to see how yours functions in action

Well, this site is not for advertisements or show. If you're really interested to *see* it, contact me by EMail. I can post here some sample code only. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
John,

FWIW, I've used TechSmith's SnagIt Screen Capture to create AVI demo's. It's only a third of the price of Camtasia and offers a DDE interface.

However, AFAIK, Camtasia is one the best on the market. Check with Tom Gahagan? on the UT, he does a lot with AVI's. [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>The World Is Headed For Mutiny.....When All We Want Is Unity. - Creed[/sig]
 
Cool I'll send him a private message. Thanks Jon [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
ICQ VFP ActiveList #73897253[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top