Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing strings 3

Status
Not open for further replies.
Here are a couple of MS Articles on extracting parts of strings that I thought some might find useful.

Sample Expressions to Extract Portion of Text String


How to Parse Comma-Separated Text into Multiple Fields

Also if anyone knows of a way to seach for a carriage return/line feed in an Access query as the character to parse on, I'm sure that information would be useful as well.
 
If your software is "current", (Ms. Access 2K / VB6) ther is a function "Split" which does most of what is commonly refered to as 'Parseing'. For the retards (like a.k.a ME) there are several postings which include home grown versions of this function (Split or - mine - basSplit). The versions vary in degree of sophistiation (basSplit is probably one of the simpliest), so you should check the capabilities vs. needs.

MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thanks Michael. B-)

I have seen or written a lot of code to split text several different ways, but I still think attempting to tell Access that you want to split on a CRLF in a query does not work.

I'll have to try playing with the VB code to see if I can use the VB const vbCRLF.
 
SteveR77,

Look at teh below. It would APPEAR that you could use my ver of split, & therefore - I Think (therefore ...)) most would work.

Not vbcrlf, but just 'plain old' vbCr

Code:
Public Sub basTestSplit()

    Dim MyText As String
    Dim MyLines As Variant
    Dim Idx As Integer
    
    'basTestSplit
    ' 52           Thei is a test
    'Trying to split a string on 'vbcrlf'
    ' 0            Thei is a test               14
    '1
    'Trying to split a string on 'vbcrlf'       37


    MyText = "Thei is a test" & vbCrLf & "Trying to split a string on 'vbcrlf'"
    Debug.Print Len(MyText), MyText

    MyLines = basSplit(MyText, vbCr)
    For Idx = 0 To UBound(MyLines)
        Debug.Print Idx, MyLines(Idx), Len(MyLines(Idx))
    Next Idx
        

End Sub
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thanks Michael!!! I will definately file this one away, and for those of you who are wondering. YES! you can call a function in a query.

Simply use the function in question on the field in the query.

HTH! & thanks again Michael.


;-) Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top