Solved

function to recognize string patterns and insert when needed

Posted on 2008-06-22
5
176 Views
Last Modified: 2008-06-25
ACCESS 2003 VBA

What I have:
table:
1 field  =  myDescriptions - memo


What I need:

function to recognize string patterns and insert when needed.


BEFORE:
3.5oz hammer
garden rake 13 inch
1/4-20 x 1    HHCS
1/4-20 X 1-1/2 HHCS
1/4-20 X 2 INCH
5/16-18 X 3/4
1/2-16 X 1 INCH SHCS
1/2-16 X 1-1/2
1/2-16 X 2
SOCKET SCREW 1/2-20 X 1
SOCKET WRENCH 1/2 COMBO


AFTER:
3.5oz hammer
garden rake 13 inch
1/4-20 x 1    HHCS
1/4-20 X 1-1/2 HHCS
1/4-20 X 2 INCH HHCS   <---- ADDED
5/16-18 X 3/4 HHCS <----  ADDED
1/2-16 X 1 INCH SHCS
1/2-16 X 1-1/2    <------ ADDED
1/2-16 X 2      <------ ADDED
SOCKET SCREW 1/2-20 X 1
SOCKET WRENCH 1/2 COMBO


The function has to sort of figure out if the string is needed above or below as needed



Thanks
fordraiders
0
Comment
Question by:fordraiders
  • 3
5 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 21843876
Hello fordraiders,

UPDATE YourTable
SET Column = Column & " HHCS"
WHERE InStr(1, Column, " x ") > 1 And Right(Column, 4) <> "SHCS" And Right(Column, 4) <> "HHCS"

Regards,

Patrick
0
 
LVL 3

Author Comment

by:fordraiders
ID: 21843894
sorry after should be:
AFTER:
3.5oz hammer
garden rake 13 inch
1/4-20 x 1    HHCS
1/4-20 X 1-1/2 HHCS
1/4-20 X 2 INCH HHCS   <---- ADDED
5/16-18 X 3/4 HHCS <----  ADDED
1/2-16 X 1 INCH SHCS
1/2-16 X 1-1/2    SHCS  <------ ADDED
1/2-16 X 2      SHCS  <------ ADDED
SOCKET SCREW 1/2-20 X 1
SOCKET WRENCH 1/2 COMBO

0
 
LVL 77

Expert Comment

by:peter57r
ID: 21843980
So how do you determine whether it should be HHCS or SHCS or nothing?

0
 
LVL 3

Author Comment

by:fordraiders
ID: 21846213
I don't know that is what I need  a function to determine?

my guess is :
first examine each record to see if only numerics exist : exception  is the  "X"

1.   1/2-16 X 1  HHCS
2.   1/4-20 x 1         <---  Just numerics and an "X"  HERE  .  no alpha term here
3.   1/4-20 X 1-1/2      <--- no alpha term here either
4.   1/4-20 X 2 INCH
5.   5/16-18 X 3/4  
6.   1/2-16 X 1 INCH SHCS
7.   1/2-16 X 1-1/2    SHCS  <------ ADDED
8.   1/2-16 X 2      SHCS  <------  added


Once we see there is no Alpha term in the next record(2) . look in the record before(1) does an alpha term exist.
yes  it is  "HHCS"
LOOK AT THE NEXT (3) does an alpha term exist.   "NO"  so ther missiing term must be  "HHCS"

Place an "HHCS"  after... 1/4-20 X 1-1/2

so go to record 4
does an lapha term exist.  it contains "INCH" , but like  "X" thi is an exception term..

so record 4 gets
4.   1/4-20 X 2 INCH  HHCS
record 5 gets
5.   5/16-18 X 3/4  HHCS

when e get to record 6
we now have a alpha term  "SHCS"

so HHCS gets thrown out (of memory sort to speak)

so we start the examination all over again...

6.   1/2-16 X 1 INCH SHCS
7.   1/2-16 X 1-1/2    SHCS  <------ ADDED
8.   1/2-16 X 2      SHCS  <------  ADDED

Thanks for looking

fordraiders





0
 
LVL 3

Author Comment

by:fordraiders
ID: 21852699
ok , lets say we have a table of terms to search for...

tblTerms
fldTerms

Data in table is:
HHCS
SHCS
FHCS
SOCKET SET




0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now