Method or Data Member not found error

CarlyS

Registered User.
Local time
Yesterday, 16:09
Joined
Oct 9, 2004
Messages
115
I am trying to set the back color of a rectangle (called SignalBox) on a report. The color depends on the value of another field, ItemStatus, which will have a value of a,b, or c. Can someone look at this code and tell me why I get this error? The report is based on a query. ItemStatus is a conditional field if that makes a difference. I can view ItemStatus in the query with no problem.
Thanks,
Carly

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
If Me.ItemStatus = c And Me.DateComplete Is Null Then
Me.SignalBox.BackColor = 255
Else
Cancel
End If

If Me.ItemStatus = b And Me.DateComplete Is Null Then
Me.SignalBox.BackColor = 65535
Else
Cancel
End If

If Me.ItemStatus = a And Me.DateCompleted Is Null Then
Me.SignalBox.BackColor = 52377
Else
Cancel
End If

End Sub
 
I would try:
If Me.ItemStatus = "c" And IsNull(Me.DateComplete) Then
 
that didn't do it...

Thanks for the reply, but unfortunately, I still get the same error. Any other ideas?
 
*AND* you can't just say Cancel. You have to set it to something.

Cancel = True
 
Thanks for heading off that problem before I got to it!

Still though, no luck with the "method or data member not found" error. Any ideas?
 
Have you changed all three If...Else...End If sections? It *is* a box or rectangle isn't it? Do you have any bogus MISSING references?
 
ItemStatus is a textbox. SignalBox is a rectangle. The error highlights the very first instance of ItemStatus, saying that it is not found. Here is what the code looks like now:

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
If Me.ItemStatus = "c" And IsNull(Me.DateComplete) Then
Me.SignalBox.BackColor = 255
Else
Cancel = True
End If

If Me.ItemStatus = "b" And IsNull(Me.DateComplete) Then
Me.SignalBox.BackColor = 65535
Else
Cancel = True
End If

If Me.ItemStatus = "a" And IsNull(Me.DateComplete) Then
Me.SignalBox.BackColor = 52377
Else
Cancel = True
End If

End Sub
 
How would I know if I had "missing or bogus references"? I have kept this pretty simple, so I would think not, but I'm not sure what that means.
 
How would I know if I had "missing or bogus references"?
While viewing your code go to Tools>References and see if any have MISSING beside them.
 
In order to reference a field in a RecordSet on a Report, that field needs to be pulled into a control on your report. Those controls need not be visible on the report. Are both ItemStatus and DateComplete available as controls on your report?
 
No--Nothing said missing. Any other reasons that might happen?
 
Ok, yes, they were both controls, but I found that there was a typo in one of them. Now, the report opens, but the fill color does not change. It's like there's no code at all. What am I missing?
 
Why do you have code to Cancel the GroupHeader2_Format() event?
 
I took that out. Still doesn't work. I also tried this, which I think says basically the same thing. This also didn't work. Any ideas?

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
If IsNull(Me.DateCompleted) Then
If Me.ItemStatus = "c" Then
Me.SignalBox.BackColor = 255
End If

If Me.ItemStatus = "b" Then
Me.SignalBox.BackColor = 65535
End If

If Me.ItemStatus = "a" Then
Me.SignalBox.BackColor = 52377
End If
End If
End Sub
 
Take this test out and see what happens. Maybe it is never Null.

If IsNull(Me.DateCompleted) Then
 
Try moving your code to a different event; maybe a DetailFormat event. Any chance you can post a stripped down version of your db that demonstrates the problem and I can play with? I'm rapidly running out of guesses.
 
That would be wonderful. Thank you for your help. Here it is...
 

Attachments

I use a Select Case structure instead of the If...End If but mainly all I did was change the initial color of the SignalBox and it started working. :D
 

Attachments

You're the best! Thank you so much for seeing this through.

Carly
 

Users who are viewing this thread

Back
Top Bottom