?
Solved

function to recognize string patterns and insert when needed

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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