Solved

Trimming characters

Posted on 2013-06-19
4
310 Views
Last Modified: 2013-06-25
I have a 2010 Microsoft Access database which has the following code that parses a text field:  

"TROPONIN-I/CTNI                                   <0.03    ng/mL"

s = Split(LabPaste, "TROPONIN-I/CTNI  ")
If UBound(s) > 0 Then
strLab = Split(Trim(s(1)), " ")(0)
strLab2 = Split(Trim(s(1)), " ")(1)
If (strLab = "<" Or strLab = ">") Then
Text863 = strLab
Text657 = strLab2
Else
Text863 = ""
Text657 = strLab
End If
Else
End If

Open in new window


The problem is that I get an error because there is no space between the "<" and the "0.03".  I need to trim off the "<" somehow and return only "0.03"

Any help would be greatly appreciated!
0
Comment
Question by:Drjdh
  • 3
4 Comments
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 39261137
I'm not sure where or why you're getting that error, but you can use Replace -

Replace(StringOrField, "<", "")

You're replaceing "<" with "" (empty/nothing)
0
 

Author Comment

by:Drjdh
ID: 39261153
I actually want to keep the "<" and place that in a field.  In the above code, if "<" is present, then it is stored in control Text863.
0
 

Accepted Solution

by:
Drjdh earned 0 total points
ID: 39264826
Here is the solution for those of you interested:

s = Split(LabPaste, "TROPONIN-I/CTNI  ")
If UBound(s) > 0 Then
strLab = Split(Trim(s(1)), " ")(0)
strLab2 = Split(Trim(s(1)), " ")(1)
Text901 = Trim(s(1))
Text902 = strLab
Text903 = IIf(InStr(strLab, "<") > 0, "<", IIf(InStr(strLab, ">") > 0, ">", ""))
Text904 = IIf(InStr(strLab, "<") > 0, Val(Mid(LabPaste, InStr(LabPaste, "<") + 1)), IIf(InStr(strLab, ">") > 0, Val(Mid(LabPaste, InStr(LabPaste, ">") + 1)), strLab))

Open in new window

0
 

Author Closing Comment

by:Drjdh
ID: 39274212
This "InStr" function was the key to this one.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

816 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

10 Experts available now in Live!

Get 1:1 Help Now