Seeing if a checkbox is checked

G

Guest

I'm using the code below. I'm trying to make sure that a checkbox is checked. It does not work for some reason. Does anyone know why??

If Me.Check175.Value = False Then
RetValue = MsgBox("Please check the report to be used.", vbOKOnly)
Exit Sub
End If

Thanks
 
B

Bruce M. Thompson

I'm using the code below. I'm trying to make sure that a checkbox is checked.
It does not work for some reason. Does anyone know why??
If Me.Check175.Value = False Then
RetValue = MsgBox("Please check the report to be used.", vbOKOnly)
Exit Sub
End If

You did not say where your code was located and, unless we can see the whole
procedure, we can't be sure why your code isn't working properly. Is there
possibly a condition being evaluated earlier in the procedure that is invoking
an "Exit Sub"?

If the checkbox must always be checked in this instance, couldn't you just set
its value?

Me.Check175.Value = True
'If any "AfterUpdate" code, then you'll need to
'explicitly call it.
 
G

Guest

Here it is... When I tried to use "Me.Check175.Value=True" I got an error also.

Private Sub Command9_Click()

If Me.Check175 = False Then
RetValue = MsgBox("Please check the report to be used.", vbOKOnly)
Exit Sub
End If

If IsNull(Me.TextID.Value) = True Then
RetValue = MsgBox("Please Enter an ID", vbOKOnly)
Exit Sub
End If

End Sub
 
A

alan fisher

Try using 0 for false and -1 for true.

-----Original Message-----
I'm using the code below. I'm trying to make sure that a
checkbox is checked. It does not work for some reason.
Does anyone know why??
 
B

Bruce M. Thompson

Double-check the spelling of the checkbox control's name. I can't see any other
reason why your code wouldn't be working.
 
S

Steve Schapel

Me,

Can you tell us what the error is? Why do you think the problem is to
do with the Me.Check175 = False part of your code? What is RetValue
supposed to be? Could the problem be resulting from this variable not
being declared correctly?

- Steve Schapel, Microsoft Access MVP
 
S

Steve Schapel

Me,

What is the meaning of RetValue, and what type of variable have you
declared it as?

- Steve Schapel, Microsoft Access MVP
 
G

Guest

I don't think that is causing the error, because if I take it out I still get the error. I think it has something to do with the IF statement.

Thanks
 
B

Bruce M. Thompson

I don't think that is causing the error, because if I take it out I still get
the error. I think it has something to do with the IF statement.

Did you verify that "Check175" is, indeed, the correct spelling for the name of
the checkbox?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top