Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2006, 05:21 PM
Registered User
 
Join Date: Oct 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding specific string

Hi, Need help. I need to strip registration numbers from strings of data using a query. This can be in various formats, for example CEo AA12AAA mdaffg12 or AA12AAA 111545 JTH. These are just a couple of them.

Does anyone suggest a way I can retrieve just the registration number (AA12AAA) from strings as above.

All help is greatly appreciated
 
Old October 30th, 2006, 12:16 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Can you identify the location of the registration number in each field. It looks like from your example that it occupies two different locations:

FieldName
CEo AA12AAA mdaffg12
AA12AAA 111545 JTH

And you want the part that says "AA12AAA" in both records?

Of course you know I have to tell you that this is not normalized to the level of atomicity that you need for this process. Any chance you can redesign the table, or are you working with old data?



mmcdonal
 
Old October 30th, 2006, 04:14 PM
Registered User
 
Join Date: Oct 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mmcdonal

Thanks for the reply. I am fully aware of the problems in this one, and yes you are correct, the tables are not normalized in the database. As you point out, the registration number is not in the same place as already shown. I was hoping that someone would know of a shortcut to getting a specific string, also the lines of the find or search functions. Another further part of this problem that is causing difficulty is the registration numbers vary,as I am sure, you well aware.

Any help is greatly appreciated
 
Old October 30th, 2006, 04:25 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So the registration number could start or end with many different characters, and be in different parts of the string... and be of different lengths? :(

I see from your sample entries that the registration number in 7 characters long, and there are two other string components: one is 3 characters in both records, and one is 8 characters in one record, and one is 6 characters in the other.

I suppose it would be too much to hope that the registration component is the only component that is ever 7 characters, and that it is always 7 characters?

If this not the case, I think a redesign is in order with some etl work.



mmcdonal
 
Old October 31st, 2006, 12:14 PM
Registered User
 
Join Date: Oct 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, you guessed it. They certainly don;t give me easy tasks here.

You have confirmed my fears and I agree, a redesign, unfortunately I have bee given the task of unraveling other peoples entires, way beyond my control.

Thanks for your help and time

martin

 
Old October 31st, 2006, 04:05 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a general pattern to the registration numbers (and the rest of the data) that can be used to recognize one from the other? If you open the table that the un-normalized entries are in, and save it in Excel as a CSV file, and write a Perl script to rearrange the data into a standard format. You can then reimport that CSV file through Excel into Access. If the data don't have unique forms that you can use grammatical rules to recognize, but there are a limited number of each, you can create arrays of them and do searches to match what goes where (much more processing intensive and harder to implement though).

 
Old October 31st, 2006, 04:09 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can write VBA to do that without having to move the data back and forth. Just create the extra normalized fields in your existing table, and then loop through the existing records and update the new fields based on regular expression syntax.

mmcdonal
 
Old November 2nd, 2006, 12:54 PM
Registered User
 
Join Date: Oct 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All
Thanks for all your help and advise on this one. I have eventually written a VBA script to loop through the narrative and check this against the current registrations, as suggested.

It is very long winded and time consuming, 180000 records to be compare to 17000 vehicles, but at least it is extracting.

Thanks again for all your help

Martin






Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding a string in the text muki XSLT 5 November 15th, 2005 11:20 PM
datagrids question -- finding a specific row bazookajoe76 C# 1 January 22nd, 2005 12:08 PM
How to retrieve specific string zorzos Excel VBA 1 August 25th, 2004 05:41 AM
finding the string before a special character srini XSLT 2 December 16th, 2003 07:57 AM
Finding a specific character within a string tp194 Classic ASP Databases 2 October 12th, 2003 10:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.