Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Re: How to achi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 16 of 23 Topic 30626 of 31576
Post > Topic >>

Re: How to achieve scalability

by Salad <oil@[EMAIL PROTECTED] > Jul 2, 2008 at 10:36 AM

Carlos Nunes-Ueno wrote:

> I have a fairly large table (700,000 rows or so) that I'd like to run a 
> process.  However, the procedure we have right now was designed with 
> tables of more like 20,000 rows and isn't able to handle it.  Access
will 
> always crash before it can complete.
> 
> Some background: the procedure is used in the process of data cleanup
and 
> is designed to process company names into a standardized form, so that
we 
> can use it to confirm data across various datasets.  The procedure takes

> input like, for example, "The Yummy and Tasty Waffle Cor****ation" or 
> "Yummy & Tasty Waffle, Incor****ated" and turns both into "TASTYWAFFLE". 

> We can then sort, link, and filter, etc. on this field along with others

> to see if there are duplicates or check if companies that have different

> IDs are in fact the same company.
> 
> Specifically, another procedure takes a specified table and field and 
> creates a new field, filling it with the contents of the original field.

> That procedure then p***** a DAO recordset and the name of the new field

> to the main procedure which then performs 11 operations to arrive at the

> "TASTYWAFFLE" stage.  Filling the new field is clearly double work and 
> I'll be triming that part out.
> 
> Now for my specific questions: Currently, the procedure takes the whole 
> contents of the field at once, and uses a lot of InStr, Mid, Left, and 
> Right functions to perform all of the operations, then moves on to the 
> next row.  It seems more direct to just read character by charater until

> I have a complete word (i.e. I hit a space or other delimiter), process 
> that bit, then move on to the next part of the field.  Which of these 
> approaches is more efficient?  Also, where could I go to find some 
> guidelines on writing the most scalable VBA code?  I know Access has 
> limitations, but I'd like to be limited by those and not by our own 
> inefficiencies.
> 
> Thanks in advance,
> 
> Carlos

You could create a column in a query like the following.  It assumes 
your field name is called CompanyName and the new calculated column will 
be called is ShortCompanyName.
	ShortCompanyName : MakeShortName([CompanyName])

I'd suggest, when testing, to create a query that selects 3 or 4 names 
from the table so it doesn't calc the entire lot in case there's a code 
error.  I used a return value type variant in case the field is null.

Drop the following code into a module.  Then run the test query.  This 
assumes you are using A2000+ that has the Split() function.

Public Function MakeShortName(strVar As Variant) As Variant
     Dim strHold As String
     Dim strAR() As String
     Dim strChar As String
     Dim i As Integer

     If Not IsNull(strVar) Then
       'strip out non-ascii chars
       For i = 1 To Len(strVar)
           strChar = UCase(Mid(strVar, i, 1))
	
	  'convert the string to only include alphanumerics and spaces
           If IsNumeric(strChar) Or (Asc(strChar) >= 65 And _
               Asc(strChar) <= 90) Or Asc(strChar) = 32 Then
               strHold = strHold & Mid(strVar, i, 1)
           End If
       Next

       'creates an array of all words with a space as the delimiter.
       strAR = Split(strHold, " ")

       strHold = ""
       For i = LBound(strAR) To UBound(strAR)
           Select Case strAR(i)
           Case "The", "And", "Or", "Corp", "Cor****ation", "Inc", "St"
           'excludes words that match
           Case Else
             strHold = strHold & strAR(i)
           End Select
       Next
     End If

     MakeShortName = strHold

End Function

I probably would not want to sort the query with 700K names on this 
calculated column.  However, you could use the function in an update 
query to update a field to hold the shortened company name that's 
indexed in order to make it fast.

Magical Freefall Tripbox
http://www.youtube.com/watch?v=5o7NLLT4nDg
 




 23 Posts in Topic:
How to achieve scalability
"Carlos Nunes-Ueno&q  2008-07-02 00:45:11 
Re: How to achieve scalability
lyle fairfield <lyle.f  2008-07-01 18:28:36 
Re: How to achieve scalability
"Carlos Nunes-Ueno&q  2008-07-02 02:05:28 
Re: How to achieve scalability
Tom van Stiphout <no.s  2008-07-01 22:02:27 
Re: How to achieve scalability
"Carlos Nunes-Ueno&q  2008-07-02 15:59:43 
Re: How to achieve scalability
"Tony Toews [MVP]&qu  2008-07-03 02:34:49 
Re: How to achieve scalability
The Frog <Mr.Frog.to.y  2008-07-02 00:40:42 
Re: How to achieve scalability
Tom van Stiphout <no.s  2008-07-02 20:49:02 
Re: How to achieve scalability
"David W. Fenton&quo  2008-07-03 22:35:23 
Re: How to achieve scalability
The Frog <Mr.Frog.to.y  2008-07-02 01:35:21 
Re: How to achieve scalability
lyle fairfield <lyle.f  2008-07-02 03:06:22 
Re: How to achieve scalability
"Carlos Nunes-Ueno&q  2008-07-02 17:07:18 
Re: How to achieve scalability
Tom van Stiphout <no.s  2008-07-02 21:07:42 
Re: How to achieve scalability
lyle fairfield <lylefa  2008-07-03 16:25:34 
Re: How to achieve scalability
lyle fairfield <lylefa  2008-07-03 23:00:50 
Re: How to achieve scalability
Salad <oil@[EMAIL PROT  2008-07-02 10:36:14 
Re: How to achieve scalability
lyle fairfield <lylefa  2008-07-03 16:26:56 
Re: How to achieve scalability
The Frog <Mr.Frog.to.y  2008-07-03 00:11:22 
Re: How to achieve scalability
Salad <oil@[EMAIL PROT  2008-07-03 07:15:10 
Re: How to achieve scalability
lyle fairfield <lyle.f  2008-07-03 07:43:01 
Re: How to achieve scalability
The Frog <Mr.Frog.to.y  2008-07-04 00:32:24 
Re: How to achieve scalability
lyle fairfield <lylefa  2008-07-04 14:42:46 
Re: How to achieve scalability
The Frog <Mr.Frog.to.y  2008-07-07 03:19:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 23:13:58 CST 2008.