Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #11281

Re: Searching for text in a memo field between two speciific sentences

From "Phil" <phil@stantonfamily.co.uk>
Newsgroups comp.databases.ms-access
Subject Re: Searching for text in a memo field between two speciific sentences
Date 2015-10-30 16:23 +0000
Organization Aioe.org NNTP Server
Message-ID <n105ip$1b4$1@speranza.aioe.org> (permalink)
References <a8d2764f-1f48-419f-a41d-ef1935a9f35a@googlegroups.com>

Show all headers | View raw


On 30/10/2015 15:02:52, David Mitchell wrote:
> We receive updates from orders via email and I am trying to select a part
> of the email to use in a field of a table.
> 
> The email has a line "Item Ordered:" followed by the product, size cost,
> etc - which is the info I need. After the info I need is the Line "Order
> Status:"
> 
> Is there a way of just selecting the words after "Item Ordered:" and
> before "Order Status:"?
> 

You are going to need the Instr function which finds one string within
another and the mid function which pulls bits of data out of a string

Try this

Function FindOrder(OrderStg As String, StartStg As String, EndStg As String,
Delimiter As String) '?FindOrder("This is the line with Item Ordered: Blue
Shirt, 16, £20.00 Order Status", "ItemOrdered", "Order Status", ",")

    Dim i As Integer, j As Integer
    Dim StartProduct As Integer
    Dim MyProduct As String
    Dim MySize As String
    Dim MyCost As String
    Dim Stg As String
    
    Stg = Trim(OrderStg)
    i = InStr(Stg, StartStg)
    StartProduct = i + Len(StartStg) + 1
j j = InStr(StartProduct, Stg, Delimiter) ' First Comma or space after the
item ordered MyProduct = Mid(Stg, StartProduct + 1, (j - StartProduct - 1))
    Debug.Print "Item: " & MyProduct
Stg Stg = Trim(Right(Stg, Len(Stg) - j)) ' Keep right hand part of order
    j = InStr(Stg, Delimiter)                   ' Comma after size
    MySize = Left(Stg, j - 1)
    Debug.Print "Size: " & Format(CDec(MySize), "Fixed")
Stg Stg = Trim(Right(Stg, Len(Stg) - j)) ' Keep right hand part of order
    j = InStr(Stg, EndStg)                      ' Comma after cost
    MyCost = Replace(Left(Stg, j - 1), "£", "")
    Debug.Print "Price: " & Format(CCur(MyCost), "Currency")
    
End Function

Phil

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-10-30 08:02 -0700
  Re: Searching for text in a memo field between two speciific sentences Patrick Finucane <patrickfinucanetx@gmail.com> - 2015-10-30 08:59 -0700
  Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-10-30 16:23 +0000
  Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 02:09 -0800
    Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-02 10:28 +0000
      Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 02:45 -0800
        Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-02 14:11 +0000
          Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 07:52 -0800
            Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-02 16:17 +0000
              Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 08:28 -0800
                Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-02 16:42 +0000
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 09:17 -0800
                Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-02 22:54 +0000
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-03 01:47 -0800
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-03 03:04 -0800
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-03 03:23 -0800
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-03 05:03 -0800
                Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-03 23:48 +0000
                Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-04 03:15 -0800
                Re: Searching for text in a memo field between two speciific sentences "Phil" <phil@stantonfamily.co.uk> - 2015-11-05 23:57 +0000
    Re: Searching for text in a memo field between two speciific sentences Patrick Finucane <patrickfinucanetx@gmail.com> - 2015-11-02 06:17 -0800
      Re: Searching for text in a memo field between two speciific sentences David Mitchell <david.smile.photography@gmail.com> - 2015-11-02 07:55 -0800

csiph-web