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

If... Then Statement Issues

Status
Not open for further replies.

smoker1

Programmer
Jun 18, 2001
76
0
0
US
Can anyone tell me why this code is not working in the OnFormat code for the detail section of a report?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me!RippedName Is Null Then
AppName.BackColor = 12632256
Else
End If

End Sub


The debugger is stating that an object is required, and it seems like it is looking for a value and not recognizing the "null" option.

Thanks in advance for your help!

Angela
 
Well, that made it past the debugger... but it's not doing what I want it to do.

Basically if the field RippedName is Null, then I want the field AppName to be highlighted (therefore the change in backcolor).

Right now the code you recommended is highlighting everything even if the field is not null.

Can you help again, please?
 
Of course, I should have done it in my first post, sorry.

You see, when you change the property, you have to change it back (when not null)

If Not Isnull(Me!RippedName) Then
AppName.BackColor = 12632256
Else
AppName.BackColor = "some other color code";-)
End If

Roy-Vidar
End Sub
 
I really appreciate your help, Roy, but it still is highlighting all the fields, even when there is data in the [RippedName] field.

Any help? Is it possibly because the RippedName and the AppName are both in the detail section, and the report has already formatted before seeing if the RippedName field is not null?? How can I get around this, if this is the case.


Angela :)
 
Try adding .value to the end of RippedName

If Not Isnull(Me!RippedName.value) Then
AppName.BackColor = 12632256
Else
AppName.BackColor = "some other color code"
End If
 
It sounds like you're talking about continuous forms? Then this behaviour you describe is normal.

What you need is conditional formatting, or if you search this forum for billpower, he has an example that works without the ConditionalFormat property, which wasn't available until access 2000.
--jsteph
 
Use the below thread.
thread181-453702

I tried billpower's code and it works.
--jsteph
 
You're right, I dont' seem to get it to work me neither, but, an alternative, is to highlight the hole row:

If Not Isnull(Me!RippedName) Then
me.Detail.BackColor = 12632256
Else
me.Detail.BackColor = "some other color code"
End If

Don't know if that helps, but this I use, and it works;-)

Perhaps some of the others might shed some light on why changing one controls properties does not work (or better, how to do it);-)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top