[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

function to recognize string patterns and insert when needed

Posted on 2008-06-22
5
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

656 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