Discussion:
Logic Field to text value
(too old to reply)
D.Cardoen
2008-12-09 17:33:06 UTC
Permalink
Goodday

I use a logic field y = visit n = not visit

I show on a form visit or not visit using form onnavigate

if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif

but this doesn't work properly

what's preferable to do ?

thanks for any reply

Dirk C
Bruce R. Roland
2008-12-09 19:47:34 UTC
Permalink
Dirk
Post by D.Cardoen
Goodday
I use a logic field y = visit n = not visit
I show on a form visit or not visit using form onnavigate
if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif
but this doesn't work properly
what's preferable to do ?
thanks for any reply
I guess my first question would be as to what value the field is actually being given (i.e, is it "T/F", "Y/N", etc.) ? when you browse the table you should be able to see what character is actually being stored there to represent logical true or logical false.

You may have to set your evaluation to look for that value rather than "true" or "False" although I am not sure on this.

Bruce
Dan Barbaria
2008-12-09 20:20:06 UTC
Permalink
Dirk,

If you are using a dbase logical field the values can be true, false or
null. I assume based on your question that the default value is null.
Perhaps you should check for true as follows:

if Form.rowset.fields["choice"].value = true
form.text1.text := "Visit"
else
form.text1.text := "No visit"
endif


Dan Barbaria
Post by D.Cardoen
Goodday
I use a logic field y = visit n = not visit
I show on a form visit or not visit using form onnavigate
if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif
but this doesn't work properly
what's preferable to do ?
thanks for any reply
Dirk C
D.Cardoen
2008-12-09 22:45:11 UTC
Permalink
goodday

I think this will be the way looking for true

question is true and Null same value ?
Post by Dan Barbaria
Dirk,
If you are using a dbase logical field the values can be true, false or
null. I assume based on your question that the default value is null.
if Form.rowset.fields["choice"].value = true
form.text1.text := "Visit"
else
form.text1.text := "No visit"
endif
Dan Barbaria
Post by D.Cardoen
Goodday
I use a logic field y = visit n = not visit
I show on a form visit or not visit using form onnavigate
if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif
but this doesn't work properly
what's preferable to do ?
thanks for any reply
Dirk C
Ken Mayer [dBVIPS]
2008-12-09 23:02:57 UTC
Permalink
Post by D.Cardoen
goodday
I think this will be the way looking for true
question is true and Null same value ?
Neither. True, False and Null are all different. Null means that the
user has not touched the field in any way ... it is the default for a
logical field in dBASE. You could check for '# true' (not true) or '#
false' ...

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Bruce R. Roland
2008-12-10 04:05:05 UTC
Permalink
Dirk
Post by D.Cardoen
if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif
Playing with a sample form I created the following which worked well.

If form.testlogical.ROWSET.FIELDS["logical"].value == true
MSGBOX(" Value is true")
else
MSGBOX(" Value is false")
endif

Thus, I would think yours should work, however there is one difference I see that makes me wonder.

In your line

if Form.rowset.fields["choice"].value = false

I see no reference to the Query which I think would be needed to address the rowset.

i.e., would you need

if Form.<query object reference>.rowset.fields["choice"].value = false

instead?

Could this be the problem?

Bruce
Bruce R. Roland
2008-12-10 04:17:30 UTC
Permalink
Dirk
Post by Bruce R. Roland
Post by D.Cardoen
if Form.rowset.fields["choice"].value = false
form.text1.text := "No visit"
else
form.text1.text := "Visit"
endif
Playing with a sample form I created the following which worked well.
If form.testlogical.ROWSET.FIELDS["logical"].value == true
MSGBOX(" Value is true")
else
MSGBOX(" Value is false")
endif
Thus, I would think yours should work, however there is one difference I see that makes me wonder.
In your line
if Form.rowset.fields["choice"].value = false
I see no reference to the Query which I think would be needed to address the rowset.
i.e., would you need
if Form.<query object reference>.rowset.fields["choice"].value = false
instead?
Could this be the problem?
Just went back and tried with and without the query object reference and it seemed o work both ways ... so ...?

Is Form.text1.text correct?

Bruce
Bruce Beacham
2008-12-10 11:53:16 UTC
Permalink
Post by Bruce R. Roland
if Form.<query object reference>.rowset.fields["choice"].value = false
instead?
No need, because elsewhere he'll have code that does this:

form.rowset = form.query1.rowset

It may even be in the constructor code.


Bruce Beacham
Bruce R. Roland
2008-12-10 13:02:11 UTC
Permalink
Bruce
Post by Bruce Beacham
form.rowset = form.query1.rowset
It may even be in the constructor code.
Yeah! I realized this after I had tried it in my sample both ways and it had worked with the Form Onnavigate. I had originally missed that he had said this is where he called the function from and had been trying by calling it from the rowset which was a little different.

However, if his code is correct - which my test leads me to believe it is - I suppose the problem may not be in the evaluation of the field value but possibly rather maybe with the paramaeter assignment within the if clause instead.

I suppose the first thing to do would set a ? statement or a msgbox in the if to see if the evaluation is working to start with, then go from there. If the evaluation is correct ...

Bruce

Loading...