combobox does not want to change background color

megatronixs

Registered User.
Local time
Today, 01:50
Joined
Aug 17, 2012
Messages
719
Hi all,

I have some code to check a combo box if a date field is filled in, then the combo box can't be empty.
I can make the error message appear, but the combo box does not want to change color and it does not recognize any other than value :-(

This is the code that I have, and it does not work like I wish it could.
(I took the database over from some one else and need to make improvements on it. the field names where not created by me).

Code:
Private Sub cmbCurrentStatus_AfterUpdate() '<<<<<<<<<<<<<<<< Working on >>>>>>>>>>>>>
If IsNull(Me.[STEP 1 4 check current status]) And Not IsNull(Me.[Checked__date_]) Then
    MsgBox "Checked (date) can't be empty if Current Status is filled in!", , "Incomplete Form!"
        Me.[STEP 1 4 check current status].Value = RGB(255, 0, 0)
        Else
            Me.[STEP 1 4 check current status].BackColor = RGB(255, 255, 255)
    End If
End Sub
 
If you want to change the colour then do it, what you have now is only changing the value of [STEP 1 4 check current status] control, look at the two code line and compare them:
Code:
  Me.[STEP 1 4 check current status][B][COLOR=Red].Value[/COLOR][/B] = RGB(255, 0, 0)
Else
[FONT=&quot]  Me.[STEP 1 4 check current status][B][COLOR=Red].BackColor[/COLOR][/B] = RGB(255, 255, 255)[/FONT]
 
Hi JHB,

When I type "Me.[STEP 1 4 check current status]" after the dot I only get the "Value" to choose from. it will not recognize ".BackColor = RGB(255, 255, 255)"
I just left the above code per mistake there :-(

Greetings
 
What if you just type in ".BackColor"?
Else post your database with some sample data!
 
Hi,

When I type ".BackColor" it will give no error on the vba editor, only when I run it I get: Compile error: Method or data member not found.

It is strange to me as I have no clue what goes wrong there.

Greetings.
 
What is [STEP 1 4 check current status] for control-type.
Comment out the line, does it give you an error on the other line you have with the backcolor?
What about posting your database with some sample data?
 
Hi,

it is a combo box with only 2 values "Pass" and "Fail"
I can't post the database as some how the IT managed to block all uploading into web sites in the new team I work :-(
I tried to change the name of the control to pass the _ in the spaces, but the person that made the database has so many complicated queries and other things that I could not find all the places to change the name :-(
It will only work when I comment out all the lines that have the background in them.
This is just a strange situation.

Greetings.
 
Hmm - open the form in design view, which properties does the control has then?
 
Hi,

It has all the same properties as other control items in the database.
I really start to think it is the way the control is named.
When I hower over the "[STEP 1 4 check current status]" I see there: 1 = 1
So, this could be problematic one :-(

Greetings.
 
If you think it is the name, then only for problem finding, make a copy of the form, copy the control and rename it or add a new (combobox) control.
 
Hi,

I kind of feel like a donkey :-(
I did use the field name the value is stored on and not the name of the combobox.

Thanks for pointing this to me, I was almost loosing my health on this one :-(

BIG THANKS.

Greetings.
 
Good you got it solved! :)
 

Users who are viewing this thread

Back
Top Bottom