sort calculated field

  • Thread starter יריב החביב
  • Start date
×

יריב החביב

Hello,

We have calculated a field in a query that i want to sort.

Is it possible to do it in the same query (it don't let me do it) and how ?

or we must built another one (query) based on the original query

and sort the field in the new query ?

thank's
 
B

BruceM

In what way does it not let you sort? It may help if you post the SQL, or
at least describe in more detail what is going on.
 
×

יריב החביב

i want to sort the field shinooym: abs([shinooy])

shinooy=([shotef]/[kodem])-1

when i execute, i get a form which ask to fill the field "shotef"

thank's
 
B

BruceM

Try applying the Abs function to the calculation itself rather than to the
calculated field:

shinooym: Abs(([shotef]/[kodem])-1)

This assumes shotef is a field in the query's record source. That is,
shotef needs to be available to the query.

If this does not solve the problem, post the query's SQL. To do this, open
the query and click View >> SQL. Copy the text and paste it into your
reply.

יריב החביב said:
i want to sort the field shinooym: abs([shinooy])

shinooy=([shotef]/[kodem])-1

when i execute, i get a form which ask to fill the field "shotef"

thank's

--
תודה רבה


BruceM said:
In what way does it not let you sort? It may help if you post the SQL,
or
at least describe in more detail what is going on.
 
×

יריב החביב

thanks

if i use the original names of the fields it not make problem

but when i use 'field' as [kshotef], it's not work


Please . . .

SELECT netoonim_mahlaka.sacharmonth, netoonim_mahlaka.mahlaka,
netoonim_mahlaka.tashloomim AS kkodem, netoonim_mahlaka.tkamoot AS kshotef,
Abs(([kshotef]/[kkodem])-1) AS kshinooy
FROM netoonim_mahlaka
WHERE
(((netoonim_mahlaka.sacharmonth)=[forms]![Ttichkoor_netoonim]![combo24]))
ORDER BY Abs(([kshotef]/[kkodem])-1);

thank's again

תודה רבה


BruceM said:
Try applying the Abs function to the calculation itself rather than to the
calculated field:

shinooym: Abs(([shotef]/[kodem])-1)

This assumes shotef is a field in the query's record source. That is,
shotef needs to be available to the query.

If this does not solve the problem, post the query's SQL. To do this, open
the query and click View >> SQL. Copy the text and paste it into your
reply.

יריב החביב said:
i want to sort the field shinooym: abs([shinooy])

shinooy=([shotef]/[kodem])-1

when i execute, i get a form which ask to fill the field "shotef"

thank's

--
תודה רבה


BruceM said:
In what way does it not let you sort? It may help if you post the SQL,
or
at least describe in more detail what is going on.

Hello,

We have calculated a field in a query that i want to sort.

Is it possible to do it in the same query (it don't let me do it) and
how
?

or we must built another one (query) based on the original query

and sort the field in the new query ?

thank's
 
B

BruceM

The problem is in ORDER BY. When you use AS to refer to a field by another
name, it is called an Alias. As far as I know, Access cannot sort by an
alias or a calculation that uses alias fields. You need to use the original
names of the fields in the ORDER BY calculation.

An alternative, I think, is to create a new query based on this query.
Select all of the fields from the existing query. You should be able to
sort by the field names of this new query. I don't see an advantage to this
approach, but you could try it, if you like.


יריב החביב said:
thanks

if i use the original names of the fields it not make problem

but when i use 'field' as [kshotef], it's not work


Please . . .

SELECT netoonim_mahlaka.sacharmonth, netoonim_mahlaka.mahlaka,
netoonim_mahlaka.tashloomim AS kkodem, netoonim_mahlaka.tkamoot AS
kshotef,
Abs(([kshotef]/[kkodem])-1) AS kshinooy
FROM netoonim_mahlaka
WHERE
(((netoonim_mahlaka.sacharmonth)=[forms]![Ttichkoor_netoonim]![combo24]))
ORDER BY Abs(([kshotef]/[kkodem])-1);

thank's again

תודה רבה


BruceM said:
Try applying the Abs function to the calculation itself rather than to
the
calculated field:

shinooym: Abs(([shotef]/[kodem])-1)

This assumes shotef is a field in the query's record source. That is,
shotef needs to be available to the query.

If this does not solve the problem, post the query's SQL. To do this,
open
the query and click View >> SQL. Copy the text and paste it into your
reply.

יריב החביב said:
i want to sort the field shinooym: abs([shinooy])

shinooy=([shotef]/[kodem])-1

when i execute, i get a form which ask to fill the field "shotef"

thank's

--
תודה רבה


:

In what way does it not let you sort? It may help if you post the
SQL,
or
at least describe in more detail what is going on.

Hello,

We have calculated a field in a query that i want to sort.

Is it possible to do it in the same query (it don't let me do it)
and
how
?

or we must built another one (query) based on the original query

and sort the field in the new query ?

thank's
 
×

יריב החביב

thank you
--
תודה רבה


BruceM said:
The problem is in ORDER BY. When you use AS to refer to a field by another
name, it is called an Alias. As far as I know, Access cannot sort by an
alias or a calculation that uses alias fields. You need to use the original
names of the fields in the ORDER BY calculation.

An alternative, I think, is to create a new query based on this query.
Select all of the fields from the existing query. You should be able to
sort by the field names of this new query. I don't see an advantage to this
approach, but you could try it, if you like.


יריב החביב said:
thanks

if i use the original names of the fields it not make problem

but when i use 'field' as [kshotef], it's not work


Please . . .

SELECT netoonim_mahlaka.sacharmonth, netoonim_mahlaka.mahlaka,
netoonim_mahlaka.tashloomim AS kkodem, netoonim_mahlaka.tkamoot AS
kshotef,
Abs(([kshotef]/[kkodem])-1) AS kshinooy
FROM netoonim_mahlaka
WHERE
(((netoonim_mahlaka.sacharmonth)=[forms]![Ttichkoor_netoonim]![combo24]))
ORDER BY Abs(([kshotef]/[kkodem])-1);

thank's again

תודה רבה


BruceM said:
Try applying the Abs function to the calculation itself rather than to
the
calculated field:

shinooym: Abs(([shotef]/[kodem])-1)

This assumes shotef is a field in the query's record source. That is,
shotef needs to be available to the query.

If this does not solve the problem, post the query's SQL. To do this,
open
the query and click View >> SQL. Copy the text and paste it into your
reply.


i want to sort the field shinooym: abs([shinooy])

shinooy=([shotef]/[kodem])-1

when i execute, i get a form which ask to fill the field "shotef"

thank's

--
תודה רבה


:

In what way does it not let you sort? It may help if you post the
SQL,
or
at least describe in more detail what is going on.

Hello,

We have calculated a field in a query that i want to sort.

Is it possible to do it in the same query (it don't let me do it)
and
how
?

or we must built another one (query) based on the original query

and sort the field in the new query ?

thank's
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top