Results 1 to 15 of 15
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365

    Find Text within text

    Hi Guy's, is there a method of extracting just the email address from a text box ?

    ie i want to click on the text box and add the email address to another text box

    I am looking to do "on click" something like

    Me.txtEmailAddress = "what is in bold"



    *Your New Message
    *Name: Me on Here
    *Contact Number: 123456789
    *Email Address: memonhere@home.com
    *PostCode: GU6 6YT
    etc
    etc

    This is not saved in a table yet, I am trying to extract the email before it's saved


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Each bit is on a separate line? You can use the Split() function on the text with vbCrLf as the delimiter. Loop the result looking for "email address:", then grab everything after the colon.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi pbaldy, yes the text i am wanting to extract or code to another text box is on ie: line 4 after *Email Address:

    Kind Regards

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try what I suggested. I parse data out of emails that way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Are you able to put a quick example of this on here ? I don't think I have used the split function and vbCrlf as delimiter before

    The only string delimiter I ever used is '" & something & "'"

    I will understand and convert if I see an example,

    This would be much appreciated

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Code:
        Dim astrLines()           As String
        Dim L                     As Long
    
    
        astrLines = Split(strBody, vbCrLf)
        For L = 0 To UBound(astrLines)
          If InStr(1, astrLines(L), "Booking") > 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Hi pbaldy, i have tried messing around with you code and can i heckers get ot working!

    Code:
    
        Dim astrLines() As String, strBody As String
        Dim L As Long
        strBody = Me.txtMailMessage
        astrLines = Split(strBody, vbCrLf)
        For L = 0 To UBound(astrLines)
          If InStr(1, astrLines(L), "*Email Address:") > 0 Then
          MsgBox (astrLines)
                End If
         Next L

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    It is working, or it isn't? You'd want to use the Mid() function on the line after you've found the one with the email address.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    No it comes up type mismatch and highlights the MsgBox Line, initially it came up with For without next issue so i added next L

    I probably don't understand the code, i was thinking of adding a msgbox to confirm it's found the email but it debugs with type mismatch

    So it can't find the email i guess thats because it's debugging ??

    Much appreciate your help

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Well, you'd need to use the variable:

    MsgBox astrLines(L)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    pbaldy you absolute star, that brought the MsgBox up *Email Address: joebloggs@home.com

    How do i now extract joebloggs@home.com ???

    Fabulous

  12. #12
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Is it just a case of using Mid funtion counting the charachters upto and including the colon ?

  13. #13
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Cant seem to extract the email from msgBox *Email Address: joebloggs@home.com, how do i extract just the email ?

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,365
    Got it, thank you very much for your help on this one, have a great evening

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help and you too!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-18-2016, 09:46 AM
  2. Replies: 5
    Last Post: 02-24-2016, 10:58 PM
  3. Replies: 7
    Last Post: 05-03-2014, 11:50 AM
  4. Find records using combo box and text box
    By ihaveaquestion in forum Forms
    Replies: 1
    Last Post: 10-02-2013, 02:53 PM
  5. Replies: 3
    Last Post: 02-07-2013, 09:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums