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

    Replacing Ucase Text

    Hi Guy's, wonder if you can suggest any method for this one

    I am trying to use replace function to find Upper case text and replace with new line (<br>)

    Code:
    strMsg = "<B><u><i>Your Email Message Received</i></u></B><br>" & Replace(Me.txtMailMessage, UCase(Me.txtMailMessage), "<br><br>")     
            
            Debug.Print strMsg

    Immediate window



    Code:
    <B><u><i>Your Email Message Received</i></u></B><br><br><br>
    I can use Replace characters / text / numbers etc with newlines but wondered if replacing UCase with new Lines ?

    this way, it determines a new sentence

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    UCase is a function not literal text, so trying to search for it won't work.
    I'll be honest I'm struggling to see what you are trying to achieve?

    If you are trying to search for any word that is entirely in upper case, you would have to use regular expressions I think.

    In your example if it could work it would have added a new line to each word, as they all start with a capital letter.

    You would be better searching for ". " to identify the end of a sentence.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    UCase() is a function that converts all alpha characters in a string to upper case. It doesn't "find" upper case characters. So UCase("Abc") evaluates to "ABC".

    Access and VBA are not case sensitive by default: "A" = "a".

    Will period be the only end of sentence punctuation?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Thanks guy's

    @June7 and @Minty

    I tried using replacing full stop thinking it would do the trick but if there is www.June7@minty.com it splits this so also tried a number of replace options in 1 string to find www.June7@minty.com (don't replace) then fin any other full stops.

    I guess i may run into the question, what if punctuation isn't correct and the strMSG doesn't have a full stop at the end of each sentence like it should then another hurdle to jump.

    Will think of a different method

    thanks again guy's

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    @June7, period ? unsure of this question

  6. #6
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hello, thank you for asking June7. also thank you for visiting www.June7@minty.co.uk.You guy's are always helpful on accessforum.net, once again, thank you dave.com.

    the words not to generate a new line are red

  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    This is the best i have so far

    Code:
    strMsg = "<B><u><i>Your Email Message Received</i></u></B><br><br>" & Replace(Me.txtMailMessage, vbCrLf, "<br>")

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Minty and I thought you were trying to locate sentence endings and insert code to force new line. Search for end of sentence punctuation would be one way to locate sentence endings and insert breaks.

    Replace(string, ". ", ". <br><br>")

    This does assume end of sentence punctuation is always a period and space. String manipulation depends on consistency of structure. Unfortunately, your example shows lack of consistency.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    @Dave You seem to have missed that I said search for ". " not "."
    Note the space after the full stop.

    That is as good as you are going to do without some very clever spell checking algorithm.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Ahh @Minty sorry I missed the trick there re: space after .

    @June7, yes that is my plan but the missed trick from Minty tells me replace full stop and space for newline NOT full stop ONLY

    so if i read your suggestion correct, this should keep www.Minty.june7 as 1 word (line, phrase) but replace if there is a space after the stop

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes. That's why my comment said "period and space". Your example shows a sentence with period and no following space. So that one case will not get replaced.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replacing numbers with text at the query level
    By lonesoac0 in forum Queries
    Replies: 4
    Last Post: 09-03-2014, 03:16 PM
  2. Replies: 2
    Last Post: 07-09-2014, 06:41 PM
  3. Replacing a text with an image
    By kroll73 in forum Reports
    Replies: 1
    Last Post: 04-15-2014, 11:15 PM
  4. Replacing text for a report
    By Zaram in forum Reports
    Replies: 7
    Last Post: 02-23-2010, 12:27 PM
  5. Replacing text in my database
    By sbrobin in forum Access
    Replies: 0
    Last Post: 02-08-2009, 02:17 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