Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Paul Walters
  Where is Paul Walters?
 Gladstone
 Michigan - United States
 Paul Walters
 To: Bob Ethridge
  Where is Bob Ethridge?
 Northbrook
 Illinois - United States
 Bob Ethridge
 Tags
Subject: RE: Relative Position, not recno
Thread ID: 78133 Message ID: 78979 # Views: 3 # Ratings: 0
Version: Visual FoxPro 6 Category: Databases, Tables and SQL Server
Date: Tuesday, October 11, 2005 6:53:22 PM         
   


I have this problem when dynamically changing backcolor to emulate the ledger style with a grid that changes order. Typically my grids reindex on the Header's OnMouseUp event. I call a user defined method, recolor(), after each reindex and append blank. That method alternates number 1 and 2 between records. THISFORM.accountGrid.SETALL("dynamicbackcolor", "IIF(accounts.grid=1,RGB(218,245,251), RGB(240,240,240))", "Column") does the rest

If you absolutely want to know a records location relative to the first record in the grid you could do this. Counting from BOF() gives you the records currently sorted location in the table. Placing this counter in the table, use a field PlaceHolder.

public m.counter
store 0 to m.counter
Go top
do while !eof()
m.counter=m.counter+1
replace Yourtable.PlaceHolder with m.counter
skip
enddo &&Could someone add Beautify to the forum please? ;)

This allows you to make relative comparisons with a single pass through the table. Set focus off your grid and then back on (assuming the first record is not always the selected one). The first record displayed on the grid is your default upon focus. The formula for determining your records location would be (YourSelectedRecords.PlaceHolder-TheFirstDisplayedRecords.PlaceHolder)+1

Example Grid that displays 5 rows:
Name1 Amount1 13 && The 13th rec. in sort order is 1st record displayed
Name4 Amount2 14
Name17 Amount9 15
Name22 Amount0 16
Name02 Amount4 17

The record with 'Name22' would be the (16-13)+1=4th record currently displayed in the grid.

ENTIRE THREAD

Relative Position, not recno Posted by Bob Ethridge @ 9/27/2005 11:17:56 PM
RE: Relative Position, not recno Posted by Barbara Peisch @ 9/28/2005 1:54:18 AM
RE: Relative Position, not recno Posted by Andy Kramek @ 9/28/2005 1:13:33 PM
RE: Relative Position, not recno Posted by dan delpuerto @ 10/11/2005 4:26:08 PM
RE: Relative Position, not recno Posted by Paul Walters @ 10/11/2005 6:53:22 PM