Solved

eliminating numbers in a text field with formula in a query (MS Access)

Posted on 2014-02-05
7
467 Views
Last Modified: 2014-02-05
I have a field with values like the followings:

Banc of America Funding  2006-A Trust
Banc of America Funding  2004-2 Trust

What formula can I use in an access query to just retain

Banc of America Funding?
0
Comment
Question by:fitaliano
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:fitaliano
ID: 39836164
In other words, I want to truncate the filed as soon as the number starts
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 39836180
If all you have to worry about is year's that start with 2, then

Left(yourfield, instr(yourfield, "2") -2)

The expression uses instr() to find the "2" and then subtracts 2 to get the length of the string to extract.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39836341
Are you asking for just a query?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:fitaliano
ID: 39836370
it works but I get a #Func! error for fields without numberic values
0
 
LVL 35

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39836409
IIf(instr(yourfield, "2")  = 0, yourfield, Left(yourfield, instr(yourfield, "2") -2))
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39836456
Here is a query for first digit 0, 1, 2, or 3. Modify query if higher digits are involved.
For table a (adesc)

SELECT adesc,
left(replace(replace(replace( replace(adesc,"0","9"),  "1","9"),"2","9"),"3","9"),
instr(replace(replace(replace( replace(adesc,"0","9"),  "1","9"),"2","9"),"3","9"), "9")-1)
FROM a

Open in new window


You may need to check for null values.
0
 

Author Closing Comment

by:fitaliano
ID: 39836579
Thank you
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

856 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