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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with refreshing grid

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi!
I will understand if no one bothers to check this after my last dumb question. (It did seem to make sense at the time)[blush], but I hope you will give me another chance.

I use vfp 6.0 and have a form with a pageframe and 5 pages. One page has a grid with RecordSourceType = 1 Alias and Record Source = MyTable. Also on the page is a button that loads a form with multiple options to set up and run the report. An SQL SELECT from the same table is used as data source for the report. All works fine until the report and entry form close and my grid is left blank. The table is still in use as I can see on the status bar. I have tried refreshing in a lot of ways and tried what I have read in posts but I am not understanding something. (as usual)

I hope I have given enough info (and the needed info) for you to help me. Am I wrong to use the table for the source for the grid and SELECT from it for the cursor for the report? Would another way be better?

Thanks for any help you can give.

Judi
 
A grid will go blank whenever the control source is closed, even for a split second.

Check your code carefully, make sure you do not close the table that controls the grid. If you are making changes to the control source you will need to zap it, then append the new information, you cannot refresh it any other way.

Marcia will pop in with more technical information.



Don Higgins
 
As Don says when you lose the RECORDSOURCE of your grid you lose the grid - most annoying!

What I tend to do (especially as I often re-query the underlying table/cursor for a grid) is to use a METHOD that re-creates the properties of the grid.

All I have to do is remember to blank the RECORDSOURCE property before the RECORDSOURCE is destroyed. So just before your grid recordsource is destroyed issue:

Code:
THISFORM.MyGrid.RecordSource = ""

*** I would then re-create the RECORDSOURCE with a new query or whatever, eg

SELECT * FROM Customer WHERE State = 'CA' INTO CURSOR curMyCursor NOFILTER

THISFORM.ReGrid()

The REGRID method would then be something like:

Code:
WITH THISFORM.grdCustomers

	.RECORDSOURCE = "curMyCursor"
	.Column1.CONTROLSOURCE = "Company"
	.Column1.FONTBOLD = .T.
	.Column2.CONTROLSOURCE = "Surname"
	.Column3.CONTROLSOURCE = "First_Name"
	GO TOP IN curMyCursor
	.REFRESH()

ENDWITH

I know you could do this sort of thing with a FILTER, but I don't like the way the vertical scroll bar still represents the whole table not just the filtered set, so I just now tend to do this method and everything looks fine :)

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
I have read, and I think I've seen the effects myself, that setting the RecordSource to nothing can cause problems. I think it's when you haven't specified the source for each column.

I believe the way around this is to create a cursor with the same structure as the recordsource, zap the recordsource and then append from the cursor and run the grid Refresh method.


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks for the prompt response. I am not sure I have a solution yet, but I will work with these suggestions and see what I can come up with.

Thanks to all.

Judi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top