Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Changing Back color (2002)

    Hi,

    I have a form set to continuous form. It lists all 50 states an is used to enter sales tax. Not all states will have sales tax applied. I have the following code behind the save button:

    'Changes background color based on whether cell is null

    If IsNull(Me.SALES_TAX) Then
    Me.SALES_TAX.BackColor = vbWhite

    Else:
    Me.SALES_TAX.BackColor = 16777088

    End If

    The problem is that instead of just chaning the color for the states that have sales tax entered (or aren't null) it changes it for all the cells. How do I get it to just make cells that are not null change color.

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing Back color (2002)

    A continuous form contains only a single set of controls, repeated multiple times, so if you set the background color for a control, it will be applied throughout the form. A way to set the color for specific records based on a condition, use Conditional Formatting instead of code.
    - Open the form in design view.
    - Select SALES_TAX.
    - Select Format | Conditional Formatting...
    - Select Expression is in the dropdown list.
    - Enter Not IsNull([SALES_TAX]) in the box next to it.
    - Select the appropriate fill color.
    - Click OK.

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Changing Back color (2002)

    Perfect! Thanks for the explanation on continuous forms!!

    Thanks,
    Leesha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •