|
-
Dec 23rd, 2010, 11:31 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] query help
Hey all.
Access database, working in a VBA macro.
I'm trying to simplify a task by keeping as much as possible in database query and commands rather than doing this all in VBA.
Background:
I've built a term search and replace macro driven by an ever-growing data table of terms to search and terms to replace them with in a Word doc.
I usually just query the whole thing:
select * from tblTerms order by ID asc
and perform recordset count iterations of search and replace.
The long-term problem is that some search terms precede other terms that include the former term in the latter.
Ex:
tblTerms
ID Search Replace
1 dog canine
2 doghouse canine residence
just made up examples of course, but you can see that if dog is replaced by canine, then doghouse will never be found. The list is too long for me to reason out the terms and change them manually, so I need to automate finding any term such that a term with a higher ID number fully incorporates it, then ideally I can just switch their IDs.
Don't worry about full word match and those problems (the actual data is in Chinese!).
Something like:
select * from tblTerms where (any other row like '% given row's term %' and ID > given row's id)
then ultimately
update tblTerms set Search = smaller search term, Replace = smaller replace term
where ID = larger term's ID
and of course
update tblTerms set Search = larger search term, Replace = larger replace term
where ID = smaller term's ID
*******
The easiest way I can think of to code it is just to pull the whole data table into an array in VBA, then go through the entire array for each term and switch as necessary, and keep recursing until no changes are made, but that would not be a very efficient code.
Can any of this be moved into the query language?
(As for stored procedures, I'm pretty good with them in SQL Server, but haven't used Access's internal tools very much at all).
Thanks.
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|