dbTalk Databases Forums  

Sorting with a calculated field

comp.databases.paradox comp.databases.paradox


Discuss Sorting with a calculated field in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeanette
 
Posts: n/a

Default Sorting with a calculated field - 10-31-2006 , 03:32 PM







The have a table - CashFlow that has setGenFilter on ContractNo.
I have a form with a table frame of CashFlow that has a formula using the
StreetCode column on a form.
I added another column named StreetSort that has the same data as StreetCode
- however the code below does not sort the table

Why???

cashTbl.attach("CashFlow.DB")
sort cashTbl
on "ContractNo", "StreetSort"
endSort


Reply With Quote
  #2  
Old   
Bertil Isberg
 
Posts: n/a

Default Re: Sorting with a calculated field - 10-31-2006 , 03:57 PM






Jeanette

a) You can only sort a table with no indexes that way. So does your table
have an index or not?

b) When table is used by your form, you can't sort it, because the table is
in use.

c) If you really ned to sort the data, you should use an index, and
switchindex to the one you want to use to show the data.



--
Bertil Isberg - CTECH
Paradox buglist:
online: http://hem.bredband.net/bertilisberg/

"Jeanette" <HarrisJR (AT) bwsc (DOT) org> skrev i meddelandet
news:4547c10b$1 (AT) pnews (DOT) thedbcommunity.com...
Quote:
The have a table - CashFlow that has setGenFilter on ContractNo.
I have a form with a table frame of CashFlow that has a formula using the
StreetCode column on a form.
I added another column named StreetSort that has the same data as
StreetCode
- however the code below does not sort the table

Why???

cashTbl.attach("CashFlow.DB")
sort cashTbl
on "ContractNo", "StreetSort"
endSort




Reply With Quote
  #3  
Old   
Sundial Services
 
Posts: n/a

Default Re: Sorting with a calculated field - 10-31-2006 , 06:14 PM



Jeanette wrote:
Quote:
The have a table - CashFlow that has setGenFilter on ContractNo.
I have a form with a table frame of CashFlow that has a formula using the
StreetCode column on a form.
I added another column named StreetSort that has the same data as
StreetCode - however the code below does not sort the table

Why???

cashTbl.attach("CashFlow.DB")
sort cashTbl
on "ContractNo", "StreetSort"
endSort
You can't sort on a calculated field in Paradox. You can write logic that
will do the calculation and store the calculated result in a permanent
field, then sort on that.

There are various important restrictions on "sort," for example dealing with
keyed vs. non-keyed tables. Some tables can be sorted into themselves;
others cannot.

----
ChimneySweep(R): Fast(!) table repair at a click of the mouse!
http://www.sundialservices.com


Reply With Quote
  #4  
Old   
Jeanette
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 09:14 AM




the table CashFlow is not keyed or indexed
the tableframe does not display Year
the tableframe does not display StreetSort
the table frame does display StreetCode as a formula to display the actual
street name

I changed the sort:
cashTbl.attach("CashFlow.DB")
sort cashTbl
on "Year", "ContractNo", "StreetSort"
endSort
these are the 1st 3 columns in CashFlow - still does not sort
I can sort the table interactively

"Bertil Isberg" <ctech (AT) corel (DOT) ca> wrote:
Quote:
Jeanette

a) You can only sort a table with no indexes that way. So does your table

have an index or not?

b) When table is used by your form, you can't sort it, because the table
is
in use.

c) If you really ned to sort the data, you should use an index, and
switchindex to the one you want to use to show the data.



--
Bertil Isberg - CTECH
Paradox buglist:
online: http://hem.bredband.net/bertilisberg/

"Jeanette" <HarrisJR (AT) bwsc (DOT) org> skrev i meddelandet
news:4547c10b$1 (AT) pnews (DOT) thedbcommunity.com...

I have a table - CashFlow that has setGenFilter on ContractNo.
I have a form with a table frame of CashFlow that has a formula using
the
StreetCode column on a form.
I added another column named StreetSort that has the same data as
StreetCode
- however the code below does not sort the table

Why???

cashTbl.attach("CashFlow.DB")
sort cashTbl
on "ContractNo", "StreetSort"
endSort





Reply With Quote
  #5  
Old   
Tony McGuire
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 09:30 AM




Is the form in edit mode?

---------------------------------------------------------
Tony McGuire



Reply With Quote
  #6  
Old   
Jeanette
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 09:51 AM




form is in edit mode

"Tony McGuire" <png.paradoxcommunity@com> wrote:
Quote:
Is the form in edit mode?

---------------------------------------------------------
Tony McGuire




Reply With Quote
  #7  
Old   
Tony McGuire
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 09:59 AM




Well, if a record is locked you certainly won't be able to sort.

=======================
HELP:
"sort automatically places a full lock on the tables being sorted if the
result is written to the same table. "
=======================

Note: FULL LOCK.

Have you tried testing for success (try/fail) and inspecting for a message?

---------------------------------------------------------
Tony McGuire



Reply With Quote
  #8  
Old   
Jeanette
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 10:44 AM




Sort is done in the ARRIVE event BEFORE placing the form in edit mode. Sort
is also done before setGenFilter.
I've done this type of sort often but never in the ARRIVE event...

"Tony McGuire" <png.paradoxcommunity@com> wrote:
Quote:
Well, if a record is locked you certainly won't be able to sort.

=======================
HELP:
"sort automatically places a full lock on the tables being sorted if the

result is written to the same table. "
=======================

Note: FULL LOCK.

Have you tried testing for success (try/fail) and inspecting for a message?

---------------------------------------------------------
Tony McGuire




Reply With Quote
  #9  
Old   
Tony McGuire
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 10:49 AM




What if you move this to a pushbutton? endedit(), sort() stuff, edit()?

Does it work?

---------------------------------------------------------
Tony McGuire



Reply With Quote
  #10  
Old   
Fred Z
 
Posts: n/a

Default Re: Sorting with a calculated field - 11-01-2006 , 11:23 AM




Jeanette wrote:
Quote:
The have a table - CashFlow that has setGenFilter on ContractNo.
I have a form with a table frame of CashFlow that has a formula using the
StreetCode column on a form.
I added another column named StreetSort that has the same data as StreetCode
- however the code below does not sort the table

Why???

cashTbl.attach("CashFlow.DB")
sort cashTbl
on "ContractNo", "StreetSort"
endSort
Try testing the attach with if not cashTbl.attach("CashFlow.DB") then
msginfo("I","oops") endif. "This method fails if the value of tableName
is not valid (for example: the table name doesn't match the table type,
or conflicts with the database name)."

Also, your Arrive built in method placement for the code may conflict
with the tableframe built in Open method. Open may have opened your
tableframe and the table got locked somehow.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.