dbTalk Databases Forums  

Sorting bill of materials references

comp.databases.ms-access comp.databases.ms-access


Discuss Sorting bill of materials references in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lars P. Magnussen
 
Posts: n/a

Default Sorting bill of materials references - 03-13-2010 , 11:47 AM






In a bill of materials table I have references like C1, C2 ... C10,
C11..C100 etc.
Sorting the ref. field looks like this
C1
C10
C100
C11
...
C19
C2
C20
C21
...
How to make it C1, C2 ... C9, C10 .... ?

Best regards
Lars P. Magnussen

Reply With Quote
  #2  
Old   
Marco Pagliero
 
Posts: n/a

Default Re: Sorting bill of materials references - 03-13-2010 , 12:25 PM






On 13 Mrz., 18:47, "Lars P. Magnussen" <l... (AT) maglar (DOT) dk> wrote:
Quote:
In a bill of materials table I have references like C1, C2 ... C10,
C11..C100 etc.
Sorting the ref. field looks like this
C1
C10
C100
C11
..
C19
C2
C20
C21
..
How to make it C1, C2 ... C9, C10 .... ?
This order is the correct alphabetical order. Fault is the person who
introduced the codes C1, C10, C100 instead of C001, C010, C100.

You remove the C and take the numeric value of the rest:
SortField=val(mid$(RefField,2))
This value will sort the way you expect.

Greetings
Marco

Reply With Quote
  #3  
Old   
Lars P. Magnussen
 
Posts: n/a

Default Re: Sorting bill of materials references - 03-13-2010 , 02:03 PM



Quote:
How to make it C1, C2 ... C9, C10 .... ?
This order is the correct alphabetical order. Fault is the person who
introduced the codes C1, C10, C100 instead of C001, C010, C100.

Yes I agree, if we look at it from a database programmers view. But in
electronic schematics, normally you don't assign component ref's C001 etc.
So output from schematic is C1, C2..C10 etc.
And bill of material list for production don't look like this (at least I
have not seen that):
0805 capacitor C002-C008, C020, C100
or am I mistaken?

Quote:
You remove the C and take the numeric value of the rest:
SortField=val(mid$(RefField,2))
This value will sort the way you expect.

Yes, think I must do that to generate the lists and maybe afterwards remove
the extra zeroes in production material.

Best regards
Lars P. Magnussen

Reply With Quote
  #4  
Old   
Bob Quintal
 
Posts: n/a

Default Re: Sorting bill of materials references - 03-13-2010 , 02:58 PM



"Lars P. Magnussen" <lpm (AT) maglar (DOT) dk> wrote in
news:4b9bef87$0$281$14726298 (AT) news (DOT) sunsite.dk:

Quote:
How to make it C1, C2 ... C9, C10 .... ?
This order is the correct alphabetical order. Fault is the person
who introduced the codes C1, C10, C100 instead of C001, C010,
C100.

Yes I agree, if we look at it from a database programmers view.
But in electronic schematics, normally you don't assign component
ref's C001 etc. So output from schematic is C1, C2..C10 etc.
And bill of material list for production don't look like this (at
least I have not seen that):
0805 capacitor C002-C008, C020, C100
or am I mistaken?

You remove the C and take the numeric value of the rest:
SortField=val(mid$(RefField,2))
This value will sort the way you expect.

Yes, think I must do that to generate the lists and maybe
afterwards remove the extra zeroes in production material.

Best regards
Lars P. Magnussen

What I did is to create a user-defined function that breaks the
Reference Designator into its 2 or 3 parts. (e.g C23, C23A, C23B)
and properly aligns the numeric portion.
Unfortunately, the code is at work, and I'm at home enjoying the
weekend.

It went something like

Public Function RefDesSort(RefDes as string as string)
Dim RefType as String, RefNumber as string
dim iPTR as integer
for iPTR = 1 to len(RefDes)
if isnumeric(mid(refdes,iPTR,1)) then
RefNumber = Refnumber & mid(refdes,iPTR,1)
else
RefType = RefType & mid(refdes,iPTR,1)
end if
next iPTR
'now right justify the parts
RefDesSort = right(space(3) & Reftype,3 ) _
& right(space(5) & refnumber.5)
end function

which would make "VR1" into " VR 1"

Call the function in a query and sort using that column.

Quote:


--
Bob Quintal

PA is y I've altered my email address.

Reply With Quote
  #5  
Old   
hbinc
 
Posts: n/a

Default Re: Sorting bill of materials references - 03-13-2010 , 05:23 PM



On Mar 13, 6:47*pm, "Lars P. Magnussen" <l... (AT) maglar (DOT) dk> wrote:
Quote:
In a bill of materials table I have references like C1, C2 ... C10,
C11..C100 etc.
Sorting the ref. field looks like this
C1
C10
C100
C11
..
C19
C2
C20
C21
..
How to make it C1, C2 ... C9, C10 .... ?

Best regards
Lars P. Magnussen
If your SQL-string contains "ORDER BY Replace(" & fieldname &
",'C','',1) + 0" the field will be numerically sorted.
Beware of the quotes. For readability I put spaces around the quotes:
" ORDER BY Replace( " & fieldname & " , ' C ' , ' ' ,1) + 0 "
d d d s s
s s d


HBInc.

Reply With Quote
  #6  
Old   
Marco Pagliero
 
Posts: n/a

Default Re: Sorting bill of materials references - 03-15-2010 , 12:47 PM



On 13 Mrz., 21:03, "Lars P. Magnussen" wrote:

Quote:
Yes, think I must do that to generate the lists and maybe afterwards remove
the extra zeroes in production material.
I didn't mean that. SortField can be a temporary field that doesn't
appear at all in the reports:

select .... RefField, val(mid$(RefField,2)) as SortField, ... order by
SortField, RefField

That takes also care of the situations where you have C23A and C23B.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.