Results 1 to 9 of 9
  1. #1
    mr879 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    80

    Unhappy Changing the color in part of a string that is in a text box

    Hello I am trying to change the color of part of a string that is in a text box in a form.

    Note: This data is extracted from a SQL server so I cannot manipulate the data such as misplace the value in the text box.

    ID MI
    1234567891230 123456789123

    'if the values are the same then do nothing
    If (txtID.Value = txtMI.Value) Then

    'if the length of txtID does not equal length of txtMI and Length txtID=13 And the last string value of txtID=0 and the first 12 values of txtID=txtMI
    ElseIf (Len(txtID.Value) <> Len(txtMI.Value)) And (Len(txtID.Value) = 13) And (Right(txtID.Value, 1) = 0) And (Left(txtID.Value, 12) = txtMI.Value) Then
    'this gets the last value of txtID
    lastZero = Right(txtID.Value, 1)

    'I have tried to use this but error says object required, I believe because this is not associated with a text box


    lastZero.ForeColor = vbRed

    End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The text box can have only 1 color. (txtID)
    lastzero is not a text box and cannot have a color.

  3. #3
    mr879 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    80
    I understand that I am asking if there is a way to do it so that I can color only portion of the text.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    No. Text boxes are ALL , not partial.

  5. #5
    mr879 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2014
    Posts
    80
    So I cannot change the color in portion of a string in a text box?

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    3rd time: No. All one color.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could use three or more textboxes.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    You'll need to follow the suggestion of ItsMe in that to have one portion of the string a different color than the balance of the string requires distinctively different containers. It gets messy if you have to have a different color somewhere in the midst of the string because of the alignment of the strings. If the information you have allows you clearly identify the leading portion of a string from the trailing portion, two text boxes butted together with the left of the two "right-aligned" and the other "left-aligned" is about the only way you'll be able to present the user with what "appears" to be a single value with a portion being a different color.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    From Access 2007 forward, with a Field defined as a Memo Datatype, in Table Design the Text Format Property can be changed from Plain Text to Rich Text, which allows for this kind of thing.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 6
    Last Post: 09-10-2013, 08:37 AM
  2. Replies: 3
    Last Post: 04-28-2013, 04:10 PM
  3. Returning part of a string
    By dr4ke in forum Queries
    Replies: 7
    Last Post: 01-15-2013, 11:21 AM
  4. Changing the century part of the date.
    By Chet in forum Queries
    Replies: 2
    Last Post: 05-13-2012, 08:27 PM
  5. matching part of the string from two columns
    By hoachen in forum Queries
    Replies: 4
    Last Post: 12-20-2011, 01:54 PM

Tags for this Thread

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