[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Parse a text field in access query

Posted on 2016-10-25
8
Medium Priority
?
60 Views
Last Modified: 2016-10-25
I need to parse a text field and pull out a certain string of characters that aren't always in the same location in the text field.

The string will always start with a - followed by a decimal point and then either 3, 4, or 5 numeric values. If it doesn't follow this syntax then I just want it to return a 0. Here are some examples:

-.0002 Is what I want to parse from this example: 416SS-RD-0.2503-.0002
-.0010 Is what I want to parse from this example: INCONEL-625-RD-0.2661-.0010
-.0004 Is what I want to parse from this example: 17-4PH-RD-0.3752-.0004-AR.0002
-.0004 Is what I want to parse from this example: 304SS-SPR-TEMP-RD-0.0317-.0004X73
0
Comment
Question by:Lawrence Salvucci
[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
  • 4
  • 4
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41859145
place this in one of the column in your query

Mid([NameOfField], InStrRev([NameOfField], "."), 5)

or use a function

Function ParseInfo(vStr as string)
dim strVal as string
strVal=Mid(vStr, InStrRev(vStr, "."), 5)
ParseInfo=strVal
end function
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41859155
It seems to be working for some and not for others. I put it in my query instead of using a function.

This one it works fine for and returns .0020:

420SS-RD-0.241-.0020X1.185

This one does not when I should get .0010:

TI-ELI-RD-0.3755-.0010
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41859159
Scratch my last comment. I put this on the wrong field. Let me try it again.
0
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.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41859164
try this one


Mid(s, InStrRev(s, "-.") + 1, 5)
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41859165
Ok it's working fine now that I have it using the correct field. One question...instead of getting the #Error when it can't find that string at all how can I have it just return 0 instead?

This string should return 0 since it won't find that string in it. There are others similar to this so if it can't find that string can it just return 0?

Item: F020532 Line: 001
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41859166
sorry

Mid([NameOfField], InStrRev([NameOfField], "-.") +1, 5)
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 41859170
use this

IIF (Instr([NameOfField], "-.")>0, Mid([NameOfField], InStrRev([NameOfField], "-.") +1, 5),0)
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41859174
That worked! Thank you very much!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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 …
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…

656 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