on click change form background color?

Durien512

Registered User.
Local time
Today, 06:08
Joined
Dec 14, 2005
Messages
61
i searched around but i couldnt really find or atleast understand how to do what i want to do.
I want upon the user clicking on a checkbox for the background of the form to change to a set color??

thanks in advance:)
 
Here is the actual code to change the background of the form from grey to green. Add it to the after update event of the checkbox.

If Me.Detail.BackColor = 4227072 Then
Me.Detail.BackColor = -2147483633
Else
Me.Detail.BackColor = 4227072
End If

The ME represents the form
Detail is where the backgroung colors setting resides
BackColor is the actual setting for the forms color

This code says, after teh checkbox is selected ~ if the color is green, make it grey, if it isnt green make it green.

If you have many colors it can change to, look to useing an option group.
 
this is what i did

Private Sub ORDERTYPE_AfterUpdate()
If Me.ORDERTYPE = 3 Then
Me.Detail.BackColor = 255
'255 is red...
Else

Me.Detail.BackColor = 4227072
End If

End Sub

the issue with this is that it changes the color for all records?? i want it to change it just for that specific record on the form...
its also not storing that color change if i exit the form it goes back to gray.??
 
if i did something like this? although this code doesnt make sense or work.

Private Sub form_current()
If Me.ORDERTYPE = 3 Then
Me.Detail.BackColor = 255
If Me.ORDERTYPE = 2 Then
Me.Detail.BackColor = 22
If Me.ORDERTYPE = 1 Then
Me.Detail.BackColor = 11
End If
 
Durien512 said:
if i did something like this? although this code doesnt make sense or work.

Private Sub form_current()
If Me.ORDERTYPE = 3 Then
Me.Detail.BackColor = 255
If Me.ORDERTYPE = 2 Then
Me.Detail.BackColor = 22
If Me.ORDERTYPE = 1 Then
Me.Detail.BackColor = 11
End If

That is because those IF statments are not properly nested. Try a search on Nested If statments or ElseIF.

I believe an ElseIF would work fine there. I'm not a guru with IF statements, but I can tell you they are not properly nested.
 
You can use code to change the color of the form, when you exit the form and reload it it will be back at its original color.

As I understand it you want the color to change for a specific record. I am presuming that you are using a form to display a single record at a time, not a continuous form and not a datasheet.

do you want the color to change for all records where Me.ORDERTYPE = 3? or do you just want one specific record to show that color?

your question is not clear on this.
 
Uncle Gizmo said:
You can use code to change the color of the form, when you exit the form and reload it it will be back at its original color.

As I understand it you want the color to change for a specific record. I am presuming that you are using a form to display a single record at a time, not a continuous form and not a datasheet.

do you want the color to change for all records where Me.ORDERTYPE = 3? or do you just want one specific record to show that color?

your question is not clear on this.

What i want is for the background of the form to change to red if they click on a combo box and select cancellation which is order type '3' or what ever we make it.
Only the forms that are cancellations should have the red background. They are invoices.

One invoice 'record' at a time is displayed through the form.

I can get it to change color upon selecting cancellation but it changes the color for all the records and if i exit and go back to that record it goes back to gray which is the background default color
 
i got it to work 99% ok now...
i used the form's current event and this code..

'default gray color
If Me.ORDERTYPE = 1 Then
Me.Detail.BackColor = 15790320
Else
'255 is red
Me.Detail.BackColor = 255
End If

End Sub

now it knows to change the color by looking at the data stored in the combobox...
 

Users who are viewing this thread

Back
Top Bottom