473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access Sort of hyphen in mixed character strings -Alpha, Numeric, Special Characters

In a standard Ascii table a dash or hyphen is decimal 45. A period or dot is
decimal 46.
If I sort a table or recordset of mixed character string ascending in
Access, those strings beginning with a dot or period are first; those
beginning with a dash or hyphen are sorted as though the hyphen is not there
(that is the next non-hyphen character controls the sort order). Those that
are alpha or numeric are sorted in their normal order without regard to the
presence of a hyphen.

I have found nothing documenting this in Access but Excel's help file (check
sort order) specifically says that Excel will simply ignore the hyphens.

1. Is this the case for Access?

2. Is there a way of making Access sorts conform to ascii (I know its
Microsoft but really!)?

Thx

Kevin
Jan 21 '07 #1
6 7765
On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
In a standard Ascii table a dash or hyphen is decimal 45. A period or dot is
decimal 46.
If I sort a table or recordset of mixed character string ascending in
Access, those strings beginning with a dot or period are first; those
beginning with a dash or hyphen are sorted as though the hyphen is not there
(that is the next non-hyphen character controls the sort order). Those that
are alpha or numeric are sorted in their normal order without regard to the
presence of a hyphen.

I have found nothing documenting this in Access but Excel's help file (check
sort order) specifically says that Excel will simply ignore the hyphens.

1. Is this the case for Access?

2. Is there a way of making Access sorts conform to ascii (I know its
Microsoft but really!)?

Thx

Kevin
In a query, add a new column:
SortThis:Asc([Fieldname])

Sort on this column Asc or Desc.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 21 '07 #2
Thanks very much Fred - great solution. If I want to, in a query, to select
from a table of possible values can I ask for >= asc(FieldName) and
<=asc(fieldName) and get back all the legitimateasci values between first
and last fieldName?

Thx Much

"fredg" <fg******@example.invalidwrote in message
news:14***************************@40tude.net...
On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
>In a standard Ascii table a dash or hyphen is decimal 45. A period or dot
is
decimal 46.
If I sort a table or recordset of mixed character string ascending in
Access, those strings beginning with a dot or period are first; those
beginning with a dash or hyphen are sorted as though the hyphen is not
there
(that is the next non-hyphen character controls the sort order). Those
that
are alpha or numeric are sorted in their normal order without regard to
the
presence of a hyphen.

I have found nothing documenting this in Access but Excel's help file
(check
sort order) specifically says that Excel will simply ignore the hyphens.

1. Is this the case for Access?

2. Is there a way of making Access sorts conform to ascii (I know its
Microsoft but really!)?

Thx

Kevin

In a query, add a new column:
SortThis:Asc([Fieldname])

Sort on this column Asc or Desc.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Jan 21 '07 #3
On Sun, 21 Jan 2007 15:25:45 -0500, Kc-Mass wrote:
Thanks very much Fred - great solution. If I want to, in a query, to select
from a table of possible values can I ask for >= asc(FieldName) and
<=asc(fieldName) and get back all the legitimateasci values between first
and last fieldName?

Thx Much

"fredg" <fg******@example.invalidwrote in message
news:14***************************@40tude.net...
>On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
*** Snipped ***

I'm not at all sure of what you're asking.
As I understand your question, you would first create a new query
column:

NewColumn:Asc([FieldName])

The above column returns the ascii value of just the first character
in the field.

If you know the ascii values, to filter the field, you could use, for
example....
Between 45 and 65

Or, if you don't know the ascii values, you could use....
Between asc("-") and asc("A")

Either will return records that start with "-" through "A".

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 21 '07 #4
Let me try to be clearer.

I have a table of authority ranges. The authority ranges are coded, as
examples, as AA12 to XCDR, F.78 to F234, F-23 to F-81, etc. Those
authority ranges are tied to Roles. If you have one or more roles in the
database you are given one or more authority ranges. I have a table with
the roles and the attendent ranges of authorities, stated as upper and lower
bounds. I also have a lookup table of all possible individual authorities
AA12, AA13, etc. What I need to do is create a new table with roles and
individual authorities. I have a module that does all of that through a
series of queries.

The queries basically select from the table of all authorities, those
authorities that are >= the low bound of the range and <= the high bound of
the range and insert them in the new table with the attendent role ID.

The problem is that MS Access sees the third range in the second sentence
above, "F-23 to F-81" as being included in the second range, "F.78 to F234".
That is true because Access reads those in any ordered comparison (=,>,<) as
being "F23 to F81" and pretends the hyphen isn't there. It is only the
hyphenated authorities that are creating problems. If Access viewed these
in conformance with ascii table values it would see the elements of the
range "F-23 to F-81" as being all less than and therefore outside the range
"F.78 to F234".

Any help appreciated.

"fredg" <fg******@example.invalidwrote in message
news:vi****************************@40tude.net...
On Sun, 21 Jan 2007 15:25:45 -0500, Kc-Mass wrote:
>Thanks very much Fred - great solution. If I want to, in a query, to
select
from a table of possible values can I ask for >= asc(FieldName) and
<=asc(fieldName) and get back all the legitimateasci values between first
and last fieldName?

Thx Much

"fredg" <fg******@example.invalidwrote in message
news:14***************************@40tude.net.. .
>>On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
*** Snipped ***

I'm not at all sure of what you're asking.
As I understand your question, you would first create a new query
column:

NewColumn:Asc([FieldName])

The above column returns the ascii value of just the first character
in the field.

If you know the ascii values, to filter the field, you could use, for
example....
Between 45 and 65

Or, if you don't know the ascii values, you could use....
Between asc("-") and asc("A")

Either will return records that start with "-" through "A".

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Jan 22 '07 #5
On Mon, 22 Jan 2007 06:19:18 -0500, Kc-Mass wrote:
Let me try to be clearer.

I have a table of authority ranges. The authority ranges are coded, as
examples, as AA12 to XCDR, F.78 to F234, F-23 to F-81, etc. Those
authority ranges are tied to Roles. If you have one or more roles in the
database you are given one or more authority ranges. I have a table with
the roles and the attendent ranges of authorities, stated as upper and lower
bounds. I also have a lookup table of all possible individual authorities
AA12, AA13, etc. What I need to do is create a new table with roles and
individual authorities. I have a module that does all of that through a
series of queries.

The queries basically select from the table of all authorities, those
authorities that are >= the low bound of the range and <= the high bound of
the range and insert them in the new table with the attendent role ID.

The problem is that MS Access sees the third range in the second sentence
above, "F-23 to F-81" as being included in the second range, "F.78 to F234".
That is true because Access reads those in any ordered comparison (=,>,<) as
being "F23 to F81" and pretends the hyphen isn't there. It is only the
hyphenated authorities that are creating problems. If Access viewed these
in conformance with ascii table values it would see the elements of the
range "F-23 to F-81" as being all less than and therefore outside the range
"F.78 to F234".

Any help appreciated.

"fredg" <fg******@example.invalidwrote in message
news:vi****************************@40tude.net...
>On Sun, 21 Jan 2007 15:25:45 -0500, Kc-Mass wrote:
>>Thanks very much Fred - great solution. If I want to, in a query, to
select
from a table of possible values can I ask for >= asc(FieldName) and
<=asc(fieldName) and get back all the legitimateasci values between first
and last fieldName?

Thx Much

"fredg" <fg******@example.invalidwrote in message
news:14***************************@40tude.net. ..
On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
*** Snipped ***

I'm not at all sure of what you're asking.
As I understand your question, you would first create a new query
column:

NewColumn:Asc([FieldName])

The above column returns the ascii value of just the first character
in the field.

If you know the ascii values, to filter the field, you could use, for
example....
Between 45 and 65

Or, if you don't know the ascii values, you could use....
Between asc("-") and asc("A")

Either will return records that start with "-" through "A".

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
You can use the replace function to replace both the dot and the
hyphen just for sorting purposes. You would use, for example, an "a"
to replace the hyphen, and a higher ascii value "b" to replace the
dot.
Here is the SQL of an example Select query that sorts a column with
both dot and hyphens as well as normal data.

You can adapt this to whatever you need to do.

SELECT tblBasicData.YourField,
Replace(Replace([YourField],"-","a"),".","b") AS SortThis
FROM tblBasicData
WHERE (((tblBasicData.YourField) Is Not Null))
ORDER BY Replace(Replace([YourField],"-","a"),".","b");

Data As Entered Data Sorted
AA12 AA12
XCDR D.23
F.78 F234
F234 F-23
F-23 F-81
F-81 F.78
D.23 H-20
D-23 H-23
H-20 H.20
H.20 XCDR
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 22 '07 #6
Many Thanks

"fredg" <fg******@example.invalidwrote in message
news:17******************************@40tude.net.. .
On Mon, 22 Jan 2007 06:19:18 -0500, Kc-Mass wrote:
>Let me try to be clearer.

I have a table of authority ranges. The authority ranges are coded, as
examples, as AA12 to XCDR, F.78 to F234, F-23 to F-81, etc. Those
authority ranges are tied to Roles. If you have one or more roles in the
database you are given one or more authority ranges. I have a table with
the roles and the attendent ranges of authorities, stated as upper and
lower
bounds. I also have a lookup table of all possible individual authorities
AA12, AA13, etc. What I need to do is create a new table with roles and
individual authorities. I have a module that does all of that through a
series of queries.

The queries basically select from the table of all authorities, those
authorities that are >= the low bound of the range and <= the high bound
of
the range and insert them in the new table with the attendent role ID.

The problem is that MS Access sees the third range in the second sentence
above, "F-23 to F-81" as being included in the second range, "F.78 to
F234".
That is true because Access reads those in any ordered comparison (=,>,<)
as
being "F23 to F81" and pretends the hyphen isn't there. It is only the
hyphenated authorities that are creating problems. If Access viewed
these
in conformance with ascii table values it would see the elements of the
range "F-23 to F-81" as being all less than and therefore outside the
range
"F.78 to F234".

Any help appreciated.

"fredg" <fg******@example.invalidwrote in message
news:vi****************************@40tude.net. ..
>>On Sun, 21 Jan 2007 15:25:45 -0500, Kc-Mass wrote:

Thanks very much Fred - great solution. If I want to, in a query, to
select
from a table of possible values can I ask for >= asc(FieldName) and
<=asc(fieldName) and get back all the legitimateasci values between
first
and last fieldName?

Thx Much

"fredg" <fg******@example.invalidwrote in message
news:14***************************@40tude.net.. .
On Sun, 21 Jan 2007 13:41:16 -0500, Kc-Mass wrote:
>
*** Snipped ***

I'm not at all sure of what you're asking.
As I understand your question, you would first create a new query
column:

NewColumn:Asc([FieldName])

The above column returns the ascii value of just the first character
in the field.

If you know the ascii values, to filter the field, you could use, for
example....
Between 45 and 65

Or, if you don't know the ascii values, you could use....
Between asc("-") and asc("A")

Either will return records that start with "-" through "A".

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

You can use the replace function to replace both the dot and the
hyphen just for sorting purposes. You would use, for example, an "a"
to replace the hyphen, and a higher ascii value "b" to replace the
dot.
Here is the SQL of an example Select query that sorts a column with
both dot and hyphens as well as normal data.

You can adapt this to whatever you need to do.

SELECT tblBasicData.YourField,
Replace(Replace([YourField],"-","a"),".","b") AS SortThis
FROM tblBasicData
WHERE (((tblBasicData.YourField) Is Not Null))
ORDER BY Replace(Replace([YourField],"-","a"),".","b");

Data As Entered Data Sorted
AA12 AA12
XCDR D.23
F.78 F234
F234 F-23
F-23 F-81
F-81 F.78
D.23 H-20
D-23 H-23
H-20 H.20
H.20 XCDR
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Jan 22 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: The Bicycling Guitarist | last post by:
Hi. I found the following when trying to learn if there is such a thing as a non-breaking hyphen. Apparently Unicode has a ‑ but that is not well-supported, especially in older browsers. Somebody...
8
by: Mark | last post by:
My PHP script builds a table that is too wide to fit on the paper. Two of the columns contain strings that are more lengthy than data in the other columns. I can get the table to fit by letting...
13
by: Matt | last post by:
I would like to set the "list-style-type" to be a hyphen (-). How can I accomplish this in a style sheet. I tried list-style-type: hyphen; and list-style-type: dash; but neither worked. I also...
22
by: stevenkobes | last post by:
If a word has a hyphen in it, IE will permit a line break at the hyphen, but Firefox/Mozilla won't. Apparently the Firefox behavior is standards-compliant, but it is not what I want. Is there a...
15
by: Bill Cohagan | last post by:
I'm trying to generate class definitions from an XSD that contains something like: <xs:complexType name="foo" mixed="true"> <xs:choice minOccurs = "0" maxOccurs="unbounded"> <xs:element name =...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
3
by: Niklas Uhlin | last post by:
Why does the code below output this: "v a" (118,32,97) "w a" (119,32,97) "v b" (118,32,98) "w b" (119,32,98) "v c" (118,32,99) "w c" (119,32,99) and not this (as one would expect if...
4
by: Rubin | last post by:
1) I want to show a breaking hyphen in Mozilla 1.5.0.4 How do I do that? "Unicode standard annex #14", <http://www.unicode.org/reports/tr14/>, defines 4 breaking hyphens. <quote> Breaking...
13
by: artev | last post by:
If sort this work: var myarray= new Array(10,16,35,"0.1",8,4,22,19,1,22,35,9,26,38,40); with code function function1(a,b) {return a - b} var order02=new Array();...
14
by: william.hooper | last post by:
There is a longer article about this subject here: http://www.codeproject.com/useritems/SortedList_Bug.asp See the main article and the reply thread started by Robert Rohde. Alternatively look...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.