Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2006, 05:21 PM
Registered User
 
Join Date: Oct 2006
Location: Leigh, Lancashire, United Kingdom.
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
Reply With Quote
  #2 (permalink)  
Old October 30th, 2006, 12:16 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old October 30th, 2006, 04:14 PM
Registered User
 
Join Date: Oct 2006
Location: Leigh, Lancashire, United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old October 30th, 2006, 04:25 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #5 (permalink)  
Old October 31st, 2006, 12:14 PM
Registered User
 
Join Date: Oct 2006
Location: Leigh, Lancashire, United Kingdom.
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

Reply With Quote
  #6 (permalink)  
Old October 31st, 2006, 04:05 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , , .
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).

Reply With Quote
  #7 (permalink)  
Old October 31st, 2006, 04:09 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #8 (permalink)  
Old November 2nd, 2006, 12:54 PM
Registered User
 
Join Date: Oct 2006
Location: Leigh, Lancashire, United Kingdom.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:02 PM.


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