Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional formatting, check box=true then gray out form 1

Status
Not open for further replies.

csunsun

Technical User
Apr 29, 2003
41
US
hi,

i have a form that needs to be gray if a check box has been checked.

i am getting errors with this code:

Private Sub Form_Current()
If CheckBox = true Then
form.backcolor = 12632256
End If
End Sub

THANKS!!!!!!!!!!!!!!!
 
Hi, csunsun,

BackColor is not a property of the form object. The basic color of forms is set by your system colors. However, you can place a box control on your form such that it covers the entire form, set its back style to normal, set its border to transparent, and its style to flat. Then in your form's OnCurrent event:
Code:
If Me.MyCheck Then
    Me.Box10.BackColor = vbRed          [green]'or whatever color you wish[/green]
    Else
        Me.Box10.BackColor = vbYellow   [green]'or whatever color you wish[/green]
End If
You'll probably want to put the same code in the checkbox's AfterUpdate event so the color will change when the checkbox is checked/unchecked. And you may wish to set a default value for your checkbox, otherwise an error will be raised when you move to a new empty record.

HTH,

Ken S.
 
You may try this:
Me.Section(acDetail).BackColor = 12632256

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How are ya csunsun . . .

The sections of a form ([blue]Header/Detail/Footer[/blue]) have the [blue]BackColor[/blue] property!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top