Solved

Find a sting in a field

Posted on 2013-11-12
11
345 Views
Last Modified: 2013-11-13
I have a text field in table that I would like find any records that contain 0512 and then write the results to a seperate text field.
Example:
Original Transaction Type: C;Original Document Reference Number: 05128572;Original Accomplished Date: 2013-07-23;Adjuster DO Symbol: X0051;Original Accounting Date: 2013-07-31;***CHARGEBACK** SUPPORTING DOCUMENTS DIDN'T CONTAIN THE REQUIRED BILLING INFO. POC FOR AGENCIES: CDC-CURTIS JUE IGY9@CDC.GOV ; MCC-GUSTAVO MARRUFO  GMARRUFO@IBC.DOI.GOV

In the above example 05128572 would be written to a seperate text field.
0
Comment
Question by:shieldsco
  • 6
  • 4
11 Comments
 
LVL 57
ID: 39642854
You'll want to use InStr(), which will return the position of a string found within another string.

If Instr(strToSearch, "0512")>0 then

You can then use Mid$() to return some part of that string pased:

  strResult = Mid$(Instr(strToSearch, "0512"),10)

You can define query columns using the above as well

Jim.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39642871
you will need a vba function to do that, place this function in a regual module


Function getVarString(vMemo)
Dim s As String, vArr() As String, xStr As String
s = vMemo
if instr(s,"0512") then
vArr = Split(s, ";")
xStr = Split(vArr(1), ":")(1)
getVarString = xStr

else
getVarString = ""

end if
End Function


then create a query like this

select id, getVarString([MemoField]) from tableName



this may vary depending on the content of the memo field
0
 

Author Comment

by:shieldsco
ID: 39642917
Capricorn1-

I get the following error : Runtime 9 -- subscript out of range

xStr = Split(vArr(1), ":")(1)
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39642978
like i said 'this may vary depending on the content of the memo field "

can you upload a sample db with the table?
0
 

Author Comment

by:shieldsco
ID: 39644469
Find attached sample DB
Database8.accdb
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:shieldsco
ID: 39644578
A memo can also look like :

1. Accidentally sent invoice through on collection 05129563 without FSN
2. Reversal of Doc Ref Num: 05129859. FSN missing. Backup available upon request
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39644655
how do you want to treat this memo


LOA:11FED1110195 75090421 75-X-0512 25102 927645465 939 ZWYG  2004211101 VFC 11FED1110195

this is one of record causing the search to fail.
0
 

Author Comment

by:shieldsco
ID: 39644669
disregard
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39644691
try this, run your query and look for  columns Expr3, Expr2

you have to change your criteria
from  "*0512*"

to   "* 0512*"     ' add a space after the first *
Database8.accdb
0
 

Author Comment

by:shieldsco
ID: 39644793
I'm unable to download from my work computer - so what are the chages to the query and function -- thanks
0
 

Author Closing Comment

by:shieldsco
ID: 39644831
Thanks - very good
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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 …
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…

910 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

16 Experts available now in Live!

Get 1:1 Help Now