Results 1 to 7 of 7
  1. #1
    AccessLes is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    15

    Setting a Color on a Control For Error

    I have a continuous form. I can add/change/delete. When I add a record I try to set the backcolor to red. However all of the controls for the text box are set to red. I just want to change the backcolor of that one control to red. How can I do that?

    Here is the snippet of code. Hexcolor is a subroutine which sets the color to red.

    ElseIf IsNull(Me.SchTime) Then
    Response = MsgBox("Please enter the time", vbInformation)
    Me.SchTime.SetFocus


    Me.SchTime.BackColor = HexColor("CC0000")
    Exit Sub

  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,518
    Have you looked at Conditional Formatting (on the ribbon). It's probably the simplest way of doing what you describe.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AccessLes is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    15
    I have tried the following:

    1. I went to conditional formatting for this control
    2. I chose the expression is and entered IsNull([Me].[SchTime])=True
    3. I set the background color to red

    For some reason this doesn't work when the Me.Schtime is Null

    Any suggestions

  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,518
    "Me" is only valid in VBA code. Try:

    IsNull([SchTime])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    AccessLes is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    15
    I tried this. It work for the control, however the next control underneath also is RED. I don't understand how ACCESS works with conditional formatting. I think I need some code like this:

    If control is null then turn the control red but only this control not other controls. I really need an example. The only other way I can accomplish this,in my opinion, is to put an add button for one record. All ideas are appreciated.

    Thanks...

    Accessles

  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,518
    Can you post the db, or a sample of it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    AccessLes is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    15
    My db is over 500kb. I haven't found anything on the web that gives lots of examples of conditional formatting.

    The syntax isnull(control) = true works, however the next control down also show red. So I would like to do the following:

    1. Set the form to change/delete only
    2. Add a Add button which only shows one record and I can control the highlighting of the controls more easily.

    It just surprises me that Access can't do what want easily. I have worked over 30 years with different languages and Access doesn't seem as robust as others that I have worked on. I accept that as long as I have a work around.

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

Similar Threads

  1. syntax on setting image Picture control
    By cowboy in forum Reports
    Replies: 2
    Last Post: 02-18-2010, 10:00 AM
  2. trying to add color to texboxes
    By michaelpclisbee in forum Forms
    Replies: 2
    Last Post: 07-04-2009, 02:45 PM
  3. Row and colum color editing
    By jerald in forum Database Design
    Replies: 0
    Last Post: 03-18-2009, 05:52 PM
  4. change cell color
    By bishop743 in forum Programming
    Replies: 0
    Last Post: 02-01-2009, 11:00 AM
  5. Sending control to specific control
    By wasim_sono in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:19 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