×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Access Rich Text Memo Field Question

Access Rich Text Memo Field Question

Access Rich Text Memo Field Question

(OP)
Is there a way to search an Access (2010) rich text memo Form field with VBA code to find if the HTML tag for the red color, or any other color for that matter, is being applied somewhere in that rich text memo Form field and if it is not, then perform some VBA code? I want to use that code in a Before Update Event for another field (checkbox) on the Form to determine if red formatting was used somewhere in the Memo field and if it wasn't not update the checkbox to true and then inform the user with a MsgBox that there was no red formatting in the Rich Text Memo Form field. Thanks.

RE: Access Rich Text Memo Field Question

(OP)
Never mind. Turns out the InStr code will find the HTML snippet. You just have to be careful to limit the code being searched to something in HTML that will not be split across lines in the field being searched or InStr may not find it since it also evaluates Newline characters. Here is some sample code to do this search:

Private Sub subFindHtmlSnippet()

Dim varFound As Variant, strString1 As String, strString2 As String

strString2 = "color=red>" 'What HTML snippet are you looking for?
strString1 = Me![YourTextFieldWithRichText] 'Where are you searching for it?
varFound = InStr(1, strString1, strString2) 'Do the search
If varFound > 0 Then 'Search successful
'MsgBox "InStr returned: " & varFound 'For Testing
***Perform some code if found***
Else
'MsgBox "InStr returned: " & varFound 'For Testing
***Perform some code if NOT found***
End If

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close