G
Guest
How do I test a Yes/No field in a Macro?
If I type: [fieldname] = "Yes" in the condition field, I get a type
mismatch.
If I type: [fieldname] = "Yes" in the condition field, I get a type
mismatch.
Douglas J. Steele said:While they're named Yes/No fields, they actually hold True or False. Try
True (with no quotes), or -1 (False is 0)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
C-squared said:How do I test a Yes/No field in a Macro?
If I type: [fieldname] = "Yes" in the condition field, I get a type
mismatch.
Steve Schapel said:C²
All of these will do it:
[fieldname]=-1
[fieldname]=Yes
[fieldname]=True
--
Steve Schapel, Microsoft Access MVP
C-squared said:How do I test a Yes/No field in a Macro?
If I type: [fieldname] = "Yes" in the condition field, I get a type
mismatch.
Steve Schapel said:C²
You're absolutely sure [fieldname] it is a Yes/No data type?
What is the macro action that you are using this as a Condition for?
Maybe the 'type mismatch' is coming from somewhere else, not the
condition expression itself.
Other than that, sorry, I can't think where the problem may arise.
[fieldname]=Yes is definitely correct syntax for what you are trying to do.
--
Steve Schapel, Microsoft Access MVP
C-squared said:Thank you. I tried them all - but must be something else is getting me. What
else would cause a "type mismatch"? c2
Steve Schapel said:C²
Is fieldname represented on the form by a checkbox? Is the checkbox
also called fieldname? If so, it won't have a FontItalic property...
maybe that's the problem?
--
Steve Schapel, Microsoft Access MVP
C-squared said:Steve,
Thank you for your reply. I am sure it's a yes/no data type. The action I'm
aiming for a SetValue with [fieldname].[fontitalic] -1, and I can get it to
work with other conditions.
I made a seperate database and seperate report, I got it to work there - so
I'll keep playing with it.
C2
Steve Schapel said:C²
Is fieldname represented on the form by a checkbox? Is the checkbox
also called fieldname? If so, it won't have a FontItalic property...
maybe that's the problem?
--
Steve Schapel, Microsoft Access MVP
C-squared said:Steve,
Thank you for your reply. I am sure it's a yes/no data type. The action I'm
aiming for a SetValue with [fieldname].[fontitalic] -1, and I can get it to
work with other conditions.
I made a seperate database and seperate report, I got it to work there - so
I'll keep playing with it.
C2
Steve Schapel said:C²
Just a hint for the future, then... In newsgroup discussions it is
often good to refer to your actual field and/or control names. In your
examples, you were using [fieldname] to refer to two different things,
which doesn't necessarily make things any easier
--
Steve Schapel, Microsoft Access MVP
C-squared said:Steve,
P.S. I was not applying the FontItalic property to the checkbox (which I
didn't want displayed), but to another field.
C2