Question Sorting Issue

Johnrg

Registered User.
Local time
Tomorrow, 01:06
Joined
Sep 25, 2008
Messages
115
I have a report based on a simple query that lists product numbers and there associated details.

I have set the sorting option to ascending based on the product number.

The list looks like this:

52917
52918
52919
5292
52920

As you can see 5292 is a lower number than the others but is getting misplaced when sorted.

Is there anything I can do to fix this?

Thanks

JohnG
 
JohnG,

It is sorting properly for a text data type. To sort as a numeric data type you can try converting the field to a numeric value.

Try sorting on:

Val([YourFieldName])
 
Thanks for that answer.
Excuse my lack of knowledge but where do i put that code?
Thanks
JohnG
 
Just put it as a column in your query and sort on that column
 
In the sorting and grouping of the reort you can put
=Val([YourFieldName]) and select ascending

Brian
 
Sorry I missed it was report. Brian as usual has given the correct answer.
 
Thanks Guys,

I forgot to mention that I have a set of product codes that start with a alphabetical notation MSG:

If I sort with the =Val([Pack Number]) in the sorting and grouping options I am now getting:

MSG6234
MSG5332
MSG6235 so these product codes are now out of order followed by
4271
4273
51100
51101
51102 the straight numbers are now in order.

Not sure what to do here.

I need the numbers starting with MSG to sort ascending first in the report followed by the straight numbers to sort ascending afterwards

Any ideas?
 
Thanks Guys,

I forgot to mention that I have a set of product codes that start with a alphabetical notation MSG:

If I sort with the =Val([Pack Number]) in the sorting and grouping options I am now getting:

MSG6234
MSG5332
MSG6235 so these product codes are now out of order followed by
4271
4273
51100
51101
51102 the straight numbers are now in order.

Not sure what to do here.

I need the numbers starting with MSG to sort ascending first in the report followed by the straight numbers to sort ascending afterwards

Any ideas?

Any other things you forgot to mention? If not, then you can get it with:

=Val(Replace([YourFieldName],"MSG", ""))
 
Bob, wont that sort the MSG fields amongst the pure number fields or am I missing something.

I thing that its back to Rabbie's suggestion of doing the sort in the query, it should stay the same for the report.
However you are going to have to build an artificial sort field, probably with a vba function, if the field statts MSG then stripping the MSG away as per Bobs method, else adding say 1 million to it if not, then the MSG1234 will be sorted in order ahead of the numbers sorted in order.

Brian
 
Guys,
Heres how the report looks at the moment.
JG
 
Bob, wont that sort the MSG fields amongst the pure number fields or am I missing something.
No, I was missing the part about wanting all of those in a different location (thought they wanted it interspersed, but my bad).
 
You want this in a query and sort ascending on this

Expr1: IIf(IsNumeric(Left([yourfield],1)),Val([yourfield])+100000,Val(Replace([yourfield],"msg","")))

You could try it in the report sorting ? remember the syntax there is =formula

Brian
 

Users who are viewing this thread

Back
Top Bottom