dbTalk Databases Forums  

sorting routine in MS Access

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


Discuss sorting routine in MS Access in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Luc Beyens
 
Posts: n/a

Default sorting routine in MS Access - 07-29-2003 , 12:44 PM






I'm looking for a routine that makes correct sorst of names
I.e.: De Hondt, D'Hondt, Dhont-Beyens
the routine eliminates spaces, ', - and/or other.....

In the good old days of Dos and Basis, I wrote a routine.... and it
worked simultanously when I types a name in the appropriate field. I
created also an Name2 field.

Great thanks !!!!!

Reply With Quote
  #2  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: sorting routine in MS Access - 07-29-2003 , 01:51 PM






Actually, your old dos and basic idea is not so bad.

What you could do is in the after update event of the Name field, you could
run a tiny bit of code that strips out all spaces, and other junk.

So, in the after update event of the name field, you could go:

me!Name2 = MyStrip(Name)

You would then write a nice function in a module called MyStrip that strips
out the characters.

Then, you can base your reports, forms or export or printing of labels etc
on the real data field, but just sort on the name2 field. This is very easy,
since any form, report or even code can use a query in place of a table. So,
just make the extra field, add the above code, and then always specify the
sort order in your query to be name2.

In fact, if the file is only going to be 3 or 4 thousands records, then you
don't even need to bother with creating the field, you can create the field
at run-time in query by simply adding the MyStrip function to the query. The
reason why I speak of only 3, or 4 thousands records is that if you use a
MyStrip function as a expression in a query, then you cannot use high speed
indexing for sorting and searching. However, ms-access is so fast, that for
just a few thousand records, you don't need a index. However, after a few
thousands, I strongly recommend using index for reasons of performance (so,
depending on how many records you plan to have, you might even dispense with
the after update event, and just gen the name2 field are run time (and not
store it).


--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
kallal (AT) msn (DOT) com
http://www.attcanada.net/~kallal.msn



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.