If Statement Against a Check Box (1 Viewer)

mmaki

New member
Local time
Yesterday, 21:30
Joined
Aug 30, 2006
Messages
4
I'm trying to get the following If statement to work in a report:

Code:
Private Sub Report_Open(Cancel As Integer)
If Me.ChkPerm = Yes Then
   Me.txtBOX.BorderColor = 16711680
   Else 
   Me.txtBOX.BorderColor = 10711680
End If
End Sub

I can't get a valid "If" statement. I keep getting "You entered an expression that has no value."

What is the proper way to check an "if" statement against a check box?

Thanks,
 

FireStrike

Registered User.
Local time
Today, 00:30
Joined
Jul 14, 2006
Messages
69
try just using

If Me.ChkPerm Then
Me.txtBOX.BorderColor = 16711680
Else
Me.txtBOX.BorderColor = 10711680
End If
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:30
Joined
Aug 30, 2003
Messages
36,126
Try it in the format event of the appropriate section rather than the open event.
 

mmaki

New member
Local time
Yesterday, 21:30
Joined
Aug 30, 2006
Messages
4
That gave the same result.

Here is what I am finding out. If I place the code in another procedure like "activate" I don't get the error, but it does me no good there. It has something to do with the "open" procedure. And it's the only procedure that will do what I need.
 

mmaki

New member
Local time
Yesterday, 21:30
Joined
Aug 30, 2006
Messages
4
pbaldy, where might I find the format event of the appropriate section. I've looked and can't seem to find where else I might place this. Thanks for the response!
 

mmaki

New member
Local time
Yesterday, 21:30
Joined
Aug 30, 2006
Messages
4
pbaldy Thanks! I found it. Section Detail...Event...On Format. That did it!!!!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:30
Joined
Aug 30, 2003
Messages
36,126
Simplest way is to right click on the section (either the bar across the top of it or any empty area within it) in design view and click "Build Event". The appropriate section is of course the one containing the textbox.
 

Users who are viewing this thread

Top Bottom