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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Format?!?!

Status
Not open for further replies.
Jan 13, 2008
167
US
I created a form and when I try to conditional format it it doesn't work...

here is what i have

strDestination = me.destination

select case
case "Print Not Available"
me.destination.backcolor = vbblack
end select

that doesn't work HOWEVER this does

select case
case "Print Not Available"
me.destination = "Works"
end select

so it will allow me to change value but not backcolor or anything like that
 
In needs something to test for
Code:
strDestination = me.destination 

select case strDestination
       case "Print Not Available"
            me.destination.backcolor = vbblack
       Case Else
            Me.destination.BackColor = vbWhite
            me.destination.text = "Worked"
end select
 
I created a form with a command button and a textbox called txtDestination and ran this code.

If I type in "Testing" I get a message that says it worked and the back color stays white. If I type anything else, it turns black.

Try doing the same and paste this code in. It should work.
Note: I'm using Access 2003 but that should not matter
Code:
Private Sub Command1_Click()

Dim strTest As String

strTest = InputBox("Please enter the code.", "Testing")
Select Case strTest
    Case "Testing"
        MsgBox "It worked"
        txtDestination.BackColor = vbWhite
    Case Else
        MsgBox "Failed"
        txtDestination.BackColor = vbBlack
End Select

End Sub
 
maybe i should clarify a little more:

This is trying to read the "description" column in a form.

if that field = "Print Not Available" then the backcolor should be black. if that same field = "In Production" the backcolor should be yellow.

so???

Dim strTest As String

strTest = me!description
Select Case strTest
Case "Print Not Available"
MsgBox "It worked"
description.BackColor = vbBlack
Case Else
MsgBox "Failed"
description.BackColor = vbWhite
End Select

this sends msgbox saying it worked. However the backcolor doesn't change. Also it comes back with

"invalid use of null
 
How are ya mattloflin

Change:
description.BackColor = vbBlack
To:
[blue]Me[/blue]!description.BackColor = vbBlack


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Sorry for my ignorance, but what is a "Description Column"?

I can not find anything like that and if I try Me.Description, it's not in intelisense.

MS Access 2003
 
. . . and what about [blue]Me!description.BackColor = 0[/blue]

Check the [blue]Name[/blue] property of the control to be sure.

What version access? . . . as vbBlack is valid!

The debugger is stopping on the color line . . . yes?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Description" is the name of one of my columns on the form.

Access 2003 is the version I am using.

Also I tried Me!Description.BackColor = 0 and it's still throwing the Invalid Use of Null statement.

Here is my current code:

Public Sub Form_Current()
Dim strtest as string

strtest = Me.Description (also tried Me!Description)

select case strtest
case "print not available"
me!description.backcolor = 0
case else
me!description.backcolor = 1
end select
end sub
 
i changed it a little but still nothing

instead of all the dim strtest as string etc it is now just

select case me!description
case......
 
mattloflin . . .

On what line is the debugger stopping?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Try this:
Select Case Me!Description & ""

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You must be using a GridView on the form.

I created one and have the same problem. I'll see what I can find out.
 
yes i'm using gridview. Also the debugger is not stopping on any line right now since i changed he code to what I previously said
 
I can change the back color in code which resets the property and the form shows the change. But as soon as I run the form, it displays the back color as white

I can cycle through the properties etc. but not make the desired change.
Code:
Private Sub Form_Load()
Me.sLastName.BackColor = 2147483643

'Me.sLastName.ForeColor = 2147456690
'65280 is green
Dim MyControls As Control
For Each MyControls In Me.Controls
    MsgBox MyControls.Name & " Back Color = " & MyControls.BackColor
    If MyControls.Name = "sLastName" Then MyControls.BackColor = 65280
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top