Results 1 to 7 of 7
  1. #1
    carstenhdk is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2010
    Location
    Denmark
    Posts
    42

    Not present = red text

    Hi




    I have a form, that lists a number of students including a Yes/no -checkbox to each student. If the checkbox isnīt checked, I want the color of the students name to turn red. Whatīs the code for that?




    Thx in advance

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am attaching a sample. I have two codes one attached to the On Current Event of the Form and the other on the AfterUpdate Event of the Form. The code on the OnCurrent event ensures that the color is indicated on the Loading of the form according to the value of the CheckBox. Adding Case = Null ensures the color is same when the Value is unchecked.


    Private Sub Check5_AfterUpdate()
    Select Case Me.Check5
    Case Is = True
    Me.Text3.BackColor = RGB(225, 0, 0)
    Case Is = False
    Me.Text3.BackColor = RGB(0, 225, 0)
    End Select
    End Sub


    Private Sub Form_Current()

    Select Case Me.Check5
    Case Is = Null
    Me.Text3.BackColor = RGB(0, 225, 0)
    Case Is = True
    Me.Text3.BackColor = RGB(225, 0, 0)
    Case Is = False
    Me.Text3.BackColor = RGB(0, 225, 0)
    End Select
    End Sub

    See tha Sample attached.
    if this solves your problem mark the thread solved.

  3. #3
    carstenhdk is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2010
    Location
    Denmark
    Posts
    42
    Great! But when I change the standard show for the form as you can see on attachment. The color changes for everyone, and not just for the entry unchecked..

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Check if this solves your problem.

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    chack this one too: if you problem is solved mark the thread solved.

  6. #6
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Quote Originally Posted by carstenhdk View Post
    Hi


    I have a form, that lists a number of students including a Yes/no -checkbox to each student. If the checkbox isnīt checked, I want the color of the students name to turn red. Whatīs the code for that?




    Thx in advance
    The easiest way to do this (if Max's Edits don't work, which they probably will) would be to use Conditional Formatting.

    Select the Field with the information you want to highlight red then go to the Format Menu -> Conditional Formatting.
    Change the field that says "Field value is" to "Expression"
    Enter [myCheckBox]=No (do not put quotes around the word "No")
    Use the Format to whatever you want.

    This will change the format of that field to whatever you select on a Record by Record basis so ONLY the Records where myCheckBox is No/False will be formatted.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    "(if Max's Edits don't work, which they probably will)"


    Rawb probably you should have checked the samples attached after I posted the code I have used conditional formatting in them. The code that I posted will work in a single Form and not in a continous form.

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

Similar Threads

  1. How to vertically align text inside a text box ?
    By alexcalgary in forum Forms
    Replies: 2
    Last Post: 10-06-2010, 08:44 AM
  2. Import to text - only text value NOT importing
    By Gerry in forum Import/Export Data
    Replies: 10
    Last Post: 03-26-2010, 06:55 AM
  3. present date in data field
    By johnkl49 in forum Access
    Replies: 2
    Last Post: 09-14-2009, 04:18 PM
  4. Replies: 2
    Last Post: 07-31-2009, 06:56 AM
  5. Split text field into two text fields
    By Grant in forum Access
    Replies: 6
    Last Post: 01-31-2008, 05:52 AM

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