Solved

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

Posted on 2014-02-05
7
466 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
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: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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

803 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