[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

function to recognize string patterns and insert when needed

Posted on 2008-06-22
5
Medium Priority
?
225 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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

830 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