By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

If Statement Against a Check Box

P: 6
I'm trying to get the following If statement to work in a report:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. If Me![ChkPerm] = 0 Then
  3.     Me![txtBOX].BorderColor = 16711680
  4. Else
  5.     Me![txtBOX.BorderColor = 10711680
  6. End If
  7. 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,

Mike
Aug 30 '06 #1
Share this Question
Share on Google+
9 Replies


P: 6
Note, I have also tried many variations of
If Me![ChkPerm] = Yes Then
If Me![ChkPerm] = On Then
If Me![ChkPerm] = True Then
Aug 30 '06 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
Try the following:

Note if after you type Me. the field you want doesn't appear on the list that drops down then the field is missing from your report.

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

Note, I have also tried many variations of
If Me![ChkPerm] = Yes Then
If Me![ChkPerm] = On Then
If Me![ChkPerm] = True Then
Aug 30 '06 #3

P: 6
Just tried that with same result, "You entered an expression that has no value."

ChkPerm does appear on the list that drops down. Arghhhh
Aug 30 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Go into the report design mode and look at the field that you thought was ChkPerm. Does it exist and if so what is it named. If it is not on the report and you don't want it visible on the report than open the field list and drag it onto the report. Delete the label and make the textbox visible property to No.

Just tried that with same result, "You entered an expression that has no value."

ChkPerm does appear on the list that drops down. Arghhhh
Aug 30 '06 #5

P: 6
ChkPerm exists and it is on the form. It is named ChkPerm. I made it invisible. Makes no difference....Thanks for the suggestions though. I appreciate it.
Aug 30 '06 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
In the table containing ChkPerm have you made the default value = 0?

ChkPerm exists and it is on the form. It is named ChkPerm. I made it invisible. Makes no difference....Thanks for the suggestions though. I appreciate it.
Aug 30 '06 #7

P: 6
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.

I made the default value = 0 and still same error.
Aug 30 '06 #8

P: 6
Fixed it. Needed to place code in. Section Detail...Event...On Format

mccarthy thanks for the help!
Aug 30 '06 #9

P: n/a
Thanks for the solution - I thought I was the only VBA newbie on the internet with exactly that problem.
Sep 28 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.