Sorting Numbers with dashes in them?

C

CCR

I am having difficulty sorting numbers (page numbers) in a text block that
have dashes in them.

Example: I want to sort page # 345, 367, and pages 356-400. Each page # is
an individual entry in the query. I am already using an Iif statement
IIf([Page #] Is Null," ",Lpad([Page #]," ",10)) but admittedly (I am NOT a
coding genius, so I will take any adivce I can get!), I do not fully
understand the statement and what else I can do to make it easier/better.

The database I designed allows us to read documents and make comments to it
together, all at once (that'w what databases are all about, right??!),
without having to manually cut and paste into Word or Excel docs...

Thanks.
 
L

Lynn Trapp

I don't quite understand what you are trying to accomplish. You might want
to post a sample of what the data looks like and what kind of sort order you
have in mind.

Also, I'm afraid your IIF statement is going to have trouble running. You
are mixing Access and Oracle functions and I don't think that is going to
work. LPAD is an Oracle function that adds characters to the left side of a
string. In addition to that, your LPAD syntax is wrong. it should be
Lpad([Page #],10," "). That will add enough spaces to the left end of your
[Page #] field to make the string 10 characters long.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
C

CCR

Lynn,

Thansk for responding so quickly!

OK, I got the Iif statement formats off the Access help pages...if they are
wrong, not sure how to fix them, but...they seem to be working.

As for what I am trying to accomplish, let me see if i can frame it better
for you, I understand my original post may have been somewhat lacking in
depth...I was nervous about making the post too long...;-)

We are a group of people reviewing documents for our program. The documents
have line numbers in the draft version so we can all make comments and easily
refer back to the very spot in the doc we are looking at.

The database models the "Comments" sheet our headquarters agencies use to
matrix all the comments together when they come in. They, of course, are
using an Excel spreadsheet.

I chose to develop the database so we could all work together (at the same
time in various cubes) and not have to cut and paste the info into the
spreadsheet.

So, the headquarters doc has columns with the "Reviewer" name, "Page #,"
"Paragraph #," and "Line #" as well as fields for our comments.

I am trying to sort the comments based on the Line #, Page#, and then Para #.

It looks like this (if i can get it to post correctly):

I want the Line # to sort first and then correctly sort the remaining
coulmns. Problem is, when I sort the columns by "Line #" first, the line
numbers with dashes in them come last, probably due to the dash's ASCII
value...

One other variable...you will notice they dont seem to be in order, but they
are...one column that is missing is the "Comment Type" column and it sorts on
that column first and does it correctly. So, the first entry below startw
with Page 16. That is because that entry is a "Critical" entry and the next
several are "Substantive". Critical come first, then substantive...

Confused yet? ;- )

Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

Lynn Trapp said:
I don't quite understand what you are trying to accomplish. You might want
to post a sample of what the data looks like and what kind of sort order you
have in mind.

Also, I'm afraid your IIF statement is going to have trouble running. You
are mixing Access and Oracle functions and I don't think that is going to
work. LPAD is an Oracle function that adds characters to the left side of a
string. In addition to that, your LPAD syntax is wrong. it should be
Lpad([Page #],10," "). That will add enough spaces to the left end of your
[Page #] field to make the string 10 characters long.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


CCR said:
I am having difficulty sorting numbers (page numbers) in a text block that
have dashes in them.

Example: I want to sort page # 345, 367, and pages 356-400. Each page #
is
an individual entry in the query. I am already using an Iif statement
IIf([Page #] Is Null," ",Lpad([Page #]," ",10)) but admittedly (I am NOT a
coding genius, so I will take any adivce I can get!), I do not fully
understand the statement and what else I can do to make it easier/better.

The database I designed allows us to read documents and make comments to
it
together, all at once (that'w what databases are all about, right??!),
without having to manually cut and paste into Word or Excel docs...

Thanks.
 
L

Lynn Trapp

OK, I got the Iif statement formats off the Access help pages...if they
are
wrong, not sure how to fix them, but...they seem to be working.


Well, first of all, without seeing your whole query and knowing your table
structure, I'm not quite sure how to fix it either. I can't imagine what
Access help page would have suggested that you use LPad() inside an IIF
statement. If you have a link to that page I would like to see it.
Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

You can get your table to sort on the Page number fairly easily by doing the
following in your order by clause.

Order By CInt([Page #])

That might be more than enough to get things in a usable order, depending on
how many paragraph and line number values you have.

One thing to consider is that your Line # field violates database
normalization rules. A single field should store only a single value -- i.e.
one page number

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
C

CCR

Thanks, Lynn...and as I said, I am NOT an expert, nor trying to be...

If the Iif statement is wrong, I accept that...but it seems to be working
OK, could be just "dumb luck"... or a mystery!

Either way, not sure what to do with it, but for now, I will try your
solution.

Also, I know I am somewhat violating the rules by including a range of
pages, but several of the users were complaining that if they reference a
paragraph which includes a range of line numbers, and the block is a numeric
field, they cannot make reference to that range and it wasn't meeting their
needs so I changed it and went with this method...

Working OK now (I sorted the columns by page # first, then Para then Line
and it seems to be working now...???)

Also, I am attaching the info I got from the Access Help page concerning
"sorting numbers in non-numeric fields" which is what I am doing since I have
them in a text box.

From Microsoft Access Help Page: (Pay particular attention to the last para
which starts with "If the previous two techniques do not work for you..."
----------------------------
Sort numbers stored in a nonnumeric field

Numbers stored in a text or memo field will be sorted alphabetically, that
is, based on the first character, instead of on the numeric value. For
example, the value 11 will appear before 2, and the value 2000 will appear
before 3.

To avoid having numbers treated as text values during sorting, do one of the
following:

If the field contains only numeric values, consider changing the data type
of the field to Number or Currency.
If the field contains only numeric values, but you do not want to change the
data type of the field, or you want to ignore the nonnumeric characters when
sorting, use an expression that calls the Val function in the Advanced
Filter/Sort dialog box. If the field contains null values, use the IIf
function to treat null values as 0 or some other number.
On the Records menu, point to Filter and then click Advanced Filter/Sort.
Type the expression Expr1: IIf([Fieldname] Is Null, 0, Val([Fieldname])) in
the Field row in the first column. The IIf function checks to see if the
field value is null, and if so, treats the value as a 0. If the value is not
null, it calls the Val function to obtain the numeric equivalent.
Learn more about using expressions and functions when sorting records

An expression is like a formula that returns a value for each record. Access
uses the return values to determine the sort order of the records. While the
expression that you use will vary with your requirements, all expressions are
a combination of functions, operators, field names, and constants. To learn
how to write expressions and what operators and functions are available in
Access, see the Access Help topics About expressions and Functions (by
category).

If you need help with writing a complex expression or if an expression is
not working as expected, you can get help from communities on the Web by
posting a question to Access experts and other users. Learn about communities
with Ask the Access experts. If you want to learn more about posting
questions to communities, see the article Start getting answers from other
Office users.

In the Sort cell, select Ascending or Descending.
An ascending sort displays the record with the smallest value on top and the
record with the largest value at the bottom. A descending sort does the
opposite.

Click Apply Filter on the toolbar to sort the records.

If the previous two techniques do not work for you, make sure the values are
of the same length before sorting the records. You can do this by padding
values that contain fewer digits with leading zeroes. For example, the values
11, 2, 2000, and 3 will need to be changed to 0011, 0002, 2000, and 0003
before you apply the sort. For more information about how to pad values with
leading zeroes, see the Microsoft Knowledge Base article How to pad character
strings on left and right side. This Knowledge Base article assumes you are
familiar with writing code using Visual Basic for Applications (VBA).
-----------------------------------
They then provide a ling to this page for VBA assistance: (LPad is VBA, I
believe...???)

http://support.microsoft.com/default.aspx?scid=kb;en-us;96458

Thanks again, Lynn...I appreciate you taking the time...

CCR

Lynn Trapp said:
OK, I got the Iif statement formats off the Access help pages...if they
are
wrong, not sure how to fix them, but...they seem to be working.


Well, first of all, without seeing your whole query and knowing your table
structure, I'm not quite sure how to fix it either. I can't imagine what
Access help page would have suggested that you use LPad() inside an IIF
statement. If you have a link to that page I would like to see it.
Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

You can get your table to sort on the Page number fairly easily by doing the
following in your order by clause.

Order By CInt([Page #])

That might be more than enough to get things in a usable order, depending on
how many paragraph and line number values you have.

One thing to consider is that your Line # field violates database
normalization rules. A single field should store only a single value -- i.e.
one page number

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
N

Newbie

You could start off by normalizing your [Line #] field into two fields
eg. [StartLineNum] and [EndLineNum]

If the users give you difficulties, try to change the way they enter the
data NOT the way you store it! Would it be so difficult for users to enter
the first number in one textbox and then press the tab key to enter the
second?



CCR said:
Thanks, Lynn...and as I said, I am NOT an expert, nor trying to be...

If the Iif statement is wrong, I accept that...but it seems to be working
OK, could be just "dumb luck"... or a mystery!

Either way, not sure what to do with it, but for now, I will try your
solution.

Also, I know I am somewhat violating the rules by including a range of
pages, but several of the users were complaining that if they reference a
paragraph which includes a range of line numbers, and the block is a numeric
field, they cannot make reference to that range and it wasn't meeting their
needs so I changed it and went with this method...

Working OK now (I sorted the columns by page # first, then Para then Line
and it seems to be working now...???)

Also, I am attaching the info I got from the Access Help page concerning
"sorting numbers in non-numeric fields" which is what I am doing since I have
them in a text box.

From Microsoft Access Help Page: (Pay particular attention to the last para
which starts with "If the previous two techniques do not work for you..."
----------------------------
Sort numbers stored in a nonnumeric field

Numbers stored in a text or memo field will be sorted alphabetically, that
is, based on the first character, instead of on the numeric value. For
example, the value 11 will appear before 2, and the value 2000 will appear
before 3.

To avoid having numbers treated as text values during sorting, do one of the
following:

If the field contains only numeric values, consider changing the data type
of the field to Number or Currency.
If the field contains only numeric values, but you do not want to change the
data type of the field, or you want to ignore the nonnumeric characters when
sorting, use an expression that calls the Val function in the Advanced
Filter/Sort dialog box. If the field contains null values, use the IIf
function to treat null values as 0 or some other number.
On the Records menu, point to Filter and then click Advanced Filter/Sort.
Type the expression Expr1: IIf([Fieldname] Is Null, 0, Val([Fieldname])) in
the Field row in the first column. The IIf function checks to see if the
field value is null, and if so, treats the value as a 0. If the value is not
null, it calls the Val function to obtain the numeric equivalent.
Learn more about using expressions and functions when sorting records

An expression is like a formula that returns a value for each record. Access
uses the return values to determine the sort order of the records. While the
expression that you use will vary with your requirements, all expressions are
a combination of functions, operators, field names, and constants. To learn
how to write expressions and what operators and functions are available in
Access, see the Access Help topics About expressions and Functions (by
category).

If you need help with writing a complex expression or if an expression is
not working as expected, you can get help from communities on the Web by
posting a question to Access experts and other users. Learn about communities
with Ask the Access experts. If you want to learn more about posting
questions to communities, see the article Start getting answers from other
Office users.

In the Sort cell, select Ascending or Descending.
An ascending sort displays the record with the smallest value on top and the
record with the largest value at the bottom. A descending sort does the
opposite.

Click Apply Filter on the toolbar to sort the records.

If the previous two techniques do not work for you, make sure the values are
of the same length before sorting the records. You can do this by padding
values that contain fewer digits with leading zeroes. For example, the values
11, 2, 2000, and 3 will need to be changed to 0011, 0002, 2000, and 0003
before you apply the sort. For more information about how to pad values with
leading zeroes, see the Microsoft Knowledge Base article How to pad character
strings on left and right side. This Knowledge Base article assumes you are
familiar with writing code using Visual Basic for Applications (VBA).
-----------------------------------
They then provide a ling to this page for VBA assistance: (LPad is VBA, I
believe...???)

http://support.microsoft.com/default.aspx?scid=kb;en-us;96458

Thanks again, Lynn...I appreciate you taking the time...

CCR

Lynn Trapp said:
OK, I got the Iif statement formats off the Access help pages...if they
are
wrong, not sure how to fix them, but...they seem to be working.


Well, first of all, without seeing your whole query and knowing your table
structure, I'm not quite sure how to fix it either. I can't imagine what
Access help page would have suggested that you use LPad() inside an IIF
statement. If you have a link to that page I would like to see it.
Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

You can get your table to sort on the Page number fairly easily by doing the
following in your order by clause.

Order By CInt([Page #])

That might be more than enough to get things in a usable order, depending on
how many paragraph and line number values you have.

One thing to consider is that your Line # field violates database
normalization rules. A single field should store only a single value -- i.e.
one page number

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
C

CCR

Newbie,

that is a great idea...I never thought of that!

Guess I am too close to the forest...!

Thanks, I may give that a try...

CCR

Newbie said:
You could start off by normalizing your [Line #] field into two fields
eg. [StartLineNum] and [EndLineNum]

If the users give you difficulties, try to change the way they enter the
data NOT the way you store it! Would it be so difficult for users to enter
the first number in one textbox and then press the tab key to enter the
second?



CCR said:
Thanks, Lynn...and as I said, I am NOT an expert, nor trying to be...

If the Iif statement is wrong, I accept that...but it seems to be working
OK, could be just "dumb luck"... or a mystery!

Either way, not sure what to do with it, but for now, I will try your
solution.

Also, I know I am somewhat violating the rules by including a range of
pages, but several of the users were complaining that if they reference a
paragraph which includes a range of line numbers, and the block is a numeric
field, they cannot make reference to that range and it wasn't meeting their
needs so I changed it and went with this method...

Working OK now (I sorted the columns by page # first, then Para then Line
and it seems to be working now...???)

Also, I am attaching the info I got from the Access Help page concerning
"sorting numbers in non-numeric fields" which is what I am doing since I have
them in a text box.

From Microsoft Access Help Page: (Pay particular attention to the last para
which starts with "If the previous two techniques do not work for you..."
----------------------------
Sort numbers stored in a nonnumeric field

Numbers stored in a text or memo field will be sorted alphabetically, that
is, based on the first character, instead of on the numeric value. For
example, the value 11 will appear before 2, and the value 2000 will appear
before 3.

To avoid having numbers treated as text values during sorting, do one of the
following:

If the field contains only numeric values, consider changing the data type
of the field to Number or Currency.
If the field contains only numeric values, but you do not want to change the
data type of the field, or you want to ignore the nonnumeric characters when
sorting, use an expression that calls the Val function in the Advanced
Filter/Sort dialog box. If the field contains null values, use the IIf
function to treat null values as 0 or some other number.
On the Records menu, point to Filter and then click Advanced Filter/Sort.
Type the expression Expr1: IIf([Fieldname] Is Null, 0, Val([Fieldname])) in
the Field row in the first column. The IIf function checks to see if the
field value is null, and if so, treats the value as a 0. If the value is not
null, it calls the Val function to obtain the numeric equivalent.
Learn more about using expressions and functions when sorting records

An expression is like a formula that returns a value for each record. Access
uses the return values to determine the sort order of the records. While the
expression that you use will vary with your requirements, all expressions are
a combination of functions, operators, field names, and constants. To learn
how to write expressions and what operators and functions are available in
Access, see the Access Help topics About expressions and Functions (by
category).

If you need help with writing a complex expression or if an expression is
not working as expected, you can get help from communities on the Web by
posting a question to Access experts and other users. Learn about communities
with Ask the Access experts. If you want to learn more about posting
questions to communities, see the article Start getting answers from other
Office users.

In the Sort cell, select Ascending or Descending.
An ascending sort displays the record with the smallest value on top and the
record with the largest value at the bottom. A descending sort does the
opposite.

Click Apply Filter on the toolbar to sort the records.

If the previous two techniques do not work for you, make sure the values are
of the same length before sorting the records. You can do this by padding
values that contain fewer digits with leading zeroes. For example, the values
11, 2, 2000, and 3 will need to be changed to 0011, 0002, 2000, and 0003
before you apply the sort. For more information about how to pad values with
leading zeroes, see the Microsoft Knowledge Base article How to pad character
strings on left and right side. This Knowledge Base article assumes you are
familiar with writing code using Visual Basic for Applications (VBA).
-----------------------------------
They then provide a ling to this page for VBA assistance: (LPad is VBA, I
believe...???)

http://support.microsoft.com/default.aspx?scid=kb;en-us;96458

Thanks again, Lynn...I appreciate you taking the time...

CCR

Lynn Trapp said:
OK, I got the Iif statement formats off the Access help pages...if they
are
wrong, not sure how to fix them, but...they seem to be working.


Well, first of all, without seeing your whole query and knowing your table
structure, I'm not quite sure how to fix it either. I can't imagine what
Access help page would have suggested that you use LPad() inside an IIF
statement. If you have a link to that page I would like to see it.

Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

You can get your table to sort on the Page number fairly easily by doing the
following in your order by clause.

Order By CInt([Page #])

That might be more than enough to get things in a usable order, depending on
how many paragraph and line number values you have.

One thing to consider is that your Line # field violates database
normalization rules. A single field should store only a single value -- i.e.
one page number

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
L

Lynn Trapp

From looking at what you posted I figured ordering by the Page number would
probably work pretty good. I think newbie's suggestion for normalizing your
line numbers will solve most of the rest of it.

I see what they did now. They included a function called LPad in the article
you provided the link to. It is not a built in VBA function.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


CCR said:
Thanks, Lynn...and as I said, I am NOT an expert, nor trying to be...

If the Iif statement is wrong, I accept that...but it seems to be working
OK, could be just "dumb luck"... or a mystery!

Either way, not sure what to do with it, but for now, I will try your
solution.

Also, I know I am somewhat violating the rules by including a range of
pages, but several of the users were complaining that if they reference a
paragraph which includes a range of line numbers, and the block is a
numeric
field, they cannot make reference to that range and it wasn't meeting
their
needs so I changed it and went with this method...

Working OK now (I sorted the columns by page # first, then Para then Line
and it seems to be working now...???)

Also, I am attaching the info I got from the Access Help page concerning
"sorting numbers in non-numeric fields" which is what I am doing since I
have
them in a text box.

From Microsoft Access Help Page: (Pay particular attention to the last
para
which starts with "If the previous two techniques do not work for you..."
----------------------------
Sort numbers stored in a nonnumeric field

Numbers stored in a text or memo field will be sorted alphabetically, that
is, based on the first character, instead of on the numeric value. For
example, the value 11 will appear before 2, and the value 2000 will appear
before 3.

To avoid having numbers treated as text values during sorting, do one of
the
following:

If the field contains only numeric values, consider changing the data type
of the field to Number or Currency.
If the field contains only numeric values, but you do not want to change
the
data type of the field, or you want to ignore the nonnumeric characters
when
sorting, use an expression that calls the Val function in the Advanced
Filter/Sort dialog box. If the field contains null values, use the IIf
function to treat null values as 0 or some other number.
On the Records menu, point to Filter and then click Advanced Filter/Sort.
Type the expression Expr1: IIf([Fieldname] Is Null, 0, Val([Fieldname]))
in
the Field row in the first column. The IIf function checks to see if the
field value is null, and if so, treats the value as a 0. If the value is
not
null, it calls the Val function to obtain the numeric equivalent.
Learn more about using expressions and functions when sorting records

An expression is like a formula that returns a value for each record.
Access
uses the return values to determine the sort order of the records. While
the
expression that you use will vary with your requirements, all expressions
are
a combination of functions, operators, field names, and constants. To
learn
how to write expressions and what operators and functions are available in
Access, see the Access Help topics About expressions and Functions (by
category).

If you need help with writing a complex expression or if an expression is
not working as expected, you can get help from communities on the Web by
posting a question to Access experts and other users. Learn about
communities
with Ask the Access experts. If you want to learn more about posting
questions to communities, see the article Start getting answers from other
Office users.

In the Sort cell, select Ascending or Descending.
An ascending sort displays the record with the smallest value on top and
the
record with the largest value at the bottom. A descending sort does the
opposite.

Click Apply Filter on the toolbar to sort the records.

If the previous two techniques do not work for you, make sure the values
are
of the same length before sorting the records. You can do this by padding
values that contain fewer digits with leading zeroes. For example, the
values
11, 2, 2000, and 3 will need to be changed to 0011, 0002, 2000, and 0003
before you apply the sort. For more information about how to pad values
with
leading zeroes, see the Microsoft Knowledge Base article How to pad
character
strings on left and right side. This Knowledge Base article assumes you
are
familiar with writing code using Visual Basic for Applications (VBA).
-----------------------------------
They then provide a ling to this page for VBA assistance: (LPad is VBA, I
believe...???)

http://support.microsoft.com/default.aspx?scid=kb;en-us;96458

Thanks again, Lynn...I appreciate you taking the time...

CCR

Lynn Trapp said:
OK, I got the Iif statement formats off the Access help pages...if they
are
wrong, not sure how to fix them, but...they seem to be working.


Well, first of all, without seeing your whole query and knowing your
table
structure, I'm not quite sure how to fix it either. I can't imagine what
Access help page would have suggested that you use LPad() inside an IIF
statement. If you have a link to that page I would like to see it.
Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993

You can get your table to sort on the Page number fairly easily by doing
the
following in your order by clause.

Order By CInt([Page #])

That might be more than enough to get things in a usable order, depending
on
how many paragraph and line number values you have.

One thing to consider is that your Line # field violates database
normalization rules. A single field should store only a single value --
i.e.
one page number

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
M

Marshall Barton

CCR said:
The database models the "Comments" sheet our headquarters agencies use to
matrix all the comments together when they come in. They, of course, are
using an Excel spreadsheet.

I chose to develop the database so we could all work together (at the same
time in various cubes) and not have to cut and paste the info into the
spreadsheet.

So, the headquarters doc has columns with the "Reviewer" name, "Page #,"
"Paragraph #," and "Line #" as well as fields for our comments.

I am trying to sort the comments based on the Line #, Page#, and then Para #.

It looks like this (if i can get it to post correctly):

I want the Line # to sort first and then correctly sort the remaining
coulmns. Problem is, when I sort the columns by "Line #" first, the line
numbers with dashes in them come last, probably due to the dash's ASCII
value...

One other variable...you will notice they dont seem to be in order, but they
are...one column that is missing is the "Comment Type" column and it sorts on
that column first and does it correctly. So, the first entry below startw
with Page 16. That is because that entry is a "Critical" entry and the next
several are "Substantive". Critical come first, then substantive...

Confused yet? ;- )

Page # Para # Line #
16 1.3.8.5 677-684
2 1.2.2 460
3 1.2.2 469
8 1.3.5 571
8 1.3.6 591-594
10 1.3.7 619
16 1.3.8.5 672
16 1.3.8.5 678
23 3.1.2 1007-1009
15 1.3.8.5 669
16 1.3.8.5 671
16 1.3.8.5 674
16 1.3.8.5 688 - 690
23 3.1.2 993


There's another complication that might hit you. Access
text field sorting ignores hyphens. This mean that 1-3 will
sort after 12!?

To get what you want using text fields (whether you
normalize or not) you should convert the strings to a
numeric value. The Val function is probably appropriate for
the Line# field since it will only convert up to the first
character that's not part of a number( i.e. the hyphen).
So, I think the Line# only needs to be Val([Line #]) to
sort properly.

The paragraph number(?) is a whole 'nother can of worms.
 
C

CCR

Thank you all for your help...what a great tool this site is and what a
fantastic service!

Thanks again,

CCR
 
C

CCR

I already am!! :- ) See my new thread on filtering...

Was hoping to "lure" you back in since you were so helpful with this
thread!! ;- )
 

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