Results 1 to 4 of 4
  1. #1
    Foxy is offline Novice
    Windows XP Access 2002
    Join Date
    Apr 2013
    Posts
    2

    Problem changing background color of 'empty' text boxes on forms

    I have a multi-column combobox fed by a query. The combobox populates several text boxes in a userform when a choice is made. According to the data stored in the underlying table, some of these text boxes may display nothing when I scroll through the records.



    I would like the text boxes to have one background color when they display data and another when they do not, but the function IsNull is useless, because no text box seems to be null even if it displays no data and there is no data in the corresponding field of the underlying table. What function, if any, can I put in place of IsNull in the following code to highlight textboxes showing data? I am a newby to Access. Any help much appreciated.

    Code:
    If IsNull(TextBoxName) = True Then
    Code:
     TextBoxName.BackColor = vbWhite
    Else
     TextBoxName.BackColor = vbRed
    End If

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Try:
    Code:
    If Len(ControlName) > 0 Then
    Code:
    TextBoxName.BackColor = vbRed
    Else
      TextBoxName.BackColor = vbWhite
    End If
    
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Foxy is offline Novice
    Windows XP Access 2002
    Join Date
    Apr 2013
    Posts
    2
    Works perfect! You solved in 15 seconds what has taken me more than 10 days not to solve.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Foxy View Post
    Works perfect! You solved in 15 seconds what has taken me more than 10 days not to solve.
    I'm glad it worked for you. I have also spent many frustrated hours with Access. I think it's all part of the "learning curve".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 7
    Last Post: 10-28-2012, 02:55 PM
  2. Replies: 5
    Last Post: 09-02-2011, 03:44 PM
  3. Background Color
    By Meccer in forum Access
    Replies: 4
    Last Post: 05-30-2011, 06:49 AM
  4. Background color for fields in a subform
    By eric.opperman1@gmail.com in forum Forms
    Replies: 3
    Last Post: 03-19-2011, 07:46 PM
  5. background color in a form
    By taggart in forum Forms
    Replies: 1
    Last Post: 05-07-2009, 10:37 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