Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Issues.. again
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01162943
Message ID:
01162962
Views:
17
You're using safe select wrongly. You should select into temp cursor
select ... into cursor curTemp

zap in curDisplay
insert into curDisplay select * from curTemp

Your curDisplay should be created with CREATE CURSOR command in form's Load. You can also add all indexes there.

>I've been using this Safe Select method of repopulating grids and have run into the following issues:
>
>1. When flipping the sort of a particular field (sample follows), the grid will refresh with no data and calling Grid.Refresh() does nothing to show the data.
>
>Sample:
>
>This grid does not show all of the fields contained in the display cursor. In this case the only field not shown is the UniqueID field. Data is not shown ONLY when the user chooses to sort by the SWDN field in ASC order. I've also encountered this in other locations in this app but those are occuring on other fields (always just one). ControlSources are assigned in the INIT event of the form.
>
>I have used a browse to verify that data does exist in the Display cursor. (Curiously when doing this the grid works fine.)The SQL is well formed.
>
>
>WITH THIS
>	lsCurrentRow = curDisplay.UniqueID
>
>	ZAP IN curDisplay
>
>&& .SortOrder / .sortdirection are properties of the grid that contain field being sorted.
>&& lsAccount and lsRecordType are assigned just previous to this code.
>
>	lsSQL = 	"INSERT INTO curDisplay " +;
>			"SELECT curWorking.UniqueID, curWorking.IsSelected, " +;
>			"curWorking.Invert, curWorking.IsRestricted, " +;
>			"!ISNULL(curWorking.Annotation) as HasNote," +;
>			"curWorking.ClearDate, curRecon.SWDN, curRecon.PrimaryDoc, " +;
>			"curRecon.CAAmount, curRecon.DAAmount, curRecon.AuditDate, " +;
>			"curRecon.MachineDate, curRecon.SecondaryDoc, curRecon.Site, " +;
>			"curRecon.Source, curRecon.GLC, curRecon.ReconMonth, " +;
>			"curRecon.TransactionType, curRecon.LastRFA " +;
>		   	"FROM curWorking WITH (BUFFERING = .T.) " +;
>		   	"INNER JOIN curRecon ON curWorking.UniqueID = curRecon.UniqueID " +;
>		   	"WHERE ISNULL(curWorking.MatchedTo) AND " +;
>		   	"curRecon.RecordType = '" + lsRecordType + "' AND " +;
>			"ALLTRIM(curRecon.Account + NVL(curRecon.CFI,'')) == '" + lsAccount + "' "+;
>			IIF(THIS.Parent.chkDisplayCleared.Value, "" ,;
>				"AND ISNULL(curWorking.ClearDate) ") +;
>			"ORDER BY " + .SortOrder + " " + .SortDirection
>
>	&lsSQL.
>
>&& Keeps the same record highlighted as before the sort
>	SELECT curDisplay
>	GO TOP IN curDisplay
>	LOCATE ALL FOR curDisplay.UniqueID = lsCurrentRow
>
>	IF FOUND('curDisplay')
>		GO RECORD (RECNO('curDisplay'))
>
>	ELSE
>		GO TOP IN curDisplay
>
>	ENDIF	
>
>	.Refresh()
>
>	.AutoFit()
>	.Resize()
>
>ENDWITH	&& THIS
>
>
>2. In some circumstances, this method ignores the Controlsource assignments and populates from the table. RecordSourceType is Alias. Code in those circumstances is identical to the above. I've been using the Recordsource = '' method in these cases with no problems.
>
>Please advise.
>
>Richard
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform