If chkbox = "Yes" Then... - Doesn't work!!

  • Thread starter Thread starter haydnw
  • Start date Start date
H

haydnw

Hi,

I have the following line of code in the Detail_Format
event of a report:

If Me.chkysnCareOfMgr = "Yes" Then

Basically if the value is yes then I need to hide some
fields, if the value is no then I don't need to do
anything. However, when I run the report I get to here and
get the message 2427 "You entered an expression that has
no value".

I have exactly the same code in exactly the same place on
a different report (obviously a different control name)
and it works fine. Can anyone suggest why this might be
falling over?

Thanks very much,
haydn
 
Try using True (with no quotes) in place of Yes, i.e.:
If Me.chkysnCareOfMgr = True Then

Internally Access uses -1 as the value for True, and of course -1 is not
equal to the word "Yes".
 
Thanks for that - still not working though. Also doesn't
work if I use -1 either. :(

I have a similar situation further down in the report:

Dim strFacilNick As String
strFacilNick = txtstrNickname.Value

I get the same error message, ie that I "entered an
expression that has no value". Am I not getting the value
of the control correctly or something?? Am I supposed to
use .Value or something else?

Cheers,
H
 
Is txtstrNickname actually on the report, as a control?
If not, try adding it.

What type of field is this text box bound to? Text field?
If the value is Null, assiging to the string will fail.

Try adding "Me." in front of the reference, i.e.:
strFacilNick = Nz(Me.txtStrNickname)
If Access can see the control, it should offer it in the Intellisense.

The ".Value" bit is optional.

This is in Detail_Format, not Page_Footer_Format or something?
 
Thanks for the second reply Allen.

I have tried what you suggested, and when I use

Dim intCareOfMgr As Integer
intCareOfMgr = Nz(Me.chkysnCareOfMgr, 0)

Access does use Intellisense to fill in the name of the
control. But the error is still there! The code is in the
Detail_Format section, yes. In this case, chkysnCareOfMgr
is a Yes/No field - I've also tried using a Boolean above,
instead of an Integer, but to no avail (I filled in the
default value because it also wasn't working with no
default).

I really don't know what on earth is causing this. I tried
the same things further down in the code, where I check
against a Text field rather than a Yes/No field and the
same thing happens (it's the text field I used as an
example in my last post). Both fields are actually on the
report as controls.

Oh well, I guess some things are just fated not to be! :(

Cheers,
H
 
Back
Top