Sorting from last diget

G

Guest

I want to sort telephone numbers from the last diget of telephone numbers
because the same numbers often begin with different numbers, eg. area or
country code. But the last digets are the same. Can this be done in Access
and how?
 
D

Douglas J. Steele

Assuming your telephone numbers are stored as text (which they should be:
you'd only want to store them as numbers if you were going to do arithmetic
on them!), you can easily add a computed field in a query that uses the
Right (or Mid) function to extract only those digits of the number of
interest to you and then sort on that field.
 
D

Douglas J. Steele

If you've got the query open in the graphical query builder, you put the
function in a blank cell on the Field row.
 
G

Guest

Mr. Steele

I am still having problems with this. In an empty filed I tried the this
expression:

Right: ([Telephone], 2)
Right$: ([Telephone], 2)
=Right: ([Telephone], 2)
=Right$: ([Telephone], 2)
Right ([Telephone], 2)
Right$ ([Telephone], 2)

The name of the field in the table is: Telephone

I always get the message:

“The expression you entered contains invalid syntax. You omitted an operand
or operator, you entered an invalid character or comma, or you entered text
without surrounding it in quotation marks.â€

I would be grateful if you show me the right way to do it.

Best regards,

Chris
 
D

Douglas J. Steele

Right([Telephone], 2) should be correct. However, perhaps your regional
settings are such that you need a different delimiter. Try using a
semi-colon rather than the comma and see if that works.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Chris said:
Mr. Steele

I am still having problems with this. In an empty filed I tried the this
expression:

Right: ([Telephone], 2)
Right$: ([Telephone], 2)
=Right: ([Telephone], 2)
=Right$: ([Telephone], 2)
Right ([Telephone], 2)
Right$ ([Telephone], 2)

The name of the field in the table is: Telephone

I always get the message:

"The expression you entered contains invalid syntax. You omitted an
operand
or operator, you entered an invalid character or comma, or you entered
text
without surrounding it in quotation marks."

I would be grateful if you show me the right way to do it.

Best regards,

Chris






Douglas J. Steele said:
If you've got the query open in the graphical query builder, you put the
function in a blank cell on the Field row.
 
G

Guest

Mr. Steele

Thank you very much for your help. It was the semi-colon that did the trick.
Without your help I would not have been able to find the solution, because I
had looked through two big books about Microsoft and browsed the Internet
without result.

Best regards,

Chris

Douglas J. Steele said:
Right([Telephone], 2) should be correct. However, perhaps your regional
settings are such that you need a different delimiter. Try using a
semi-colon rather than the comma and see if that works.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Chris said:
Mr. Steele

I am still having problems with this. In an empty filed I tried the this
expression:

Right: ([Telephone], 2)
Right$: ([Telephone], 2)
=Right: ([Telephone], 2)
=Right$: ([Telephone], 2)
Right ([Telephone], 2)
Right$ ([Telephone], 2)

The name of the field in the table is: Telephone

I always get the message:

"The expression you entered contains invalid syntax. You omitted an
operand
or operator, you entered an invalid character or comma, or you entered
text
without surrounding it in quotation marks."

I would be grateful if you show me the right way to do it.

Best regards,

Chris






Douglas J. Steele said:
If you've got the query open in the graphical query builder, you put the
function in a blank cell on the Field row.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Mr. Steel

How do I add this computed field in a query?

Best regards,

Chris

:

Assuming your telephone numbers are stored as text (which they should
be:
you'd only want to store them as numbers if you were going to do
arithmetic
on them!), you can easily add a computed field in a query that uses
the
Right (or Mid) function to extract only those digits of the number of
interest to you and then sort on that field.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I want to sort telephone numbers from the last diget of telephone
numbers
because the same numbers often begin with different numbers, eg.
area
or
country code. But the last digets are the same. Can this be done in
Access
and how?
 

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