Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display "Yes" instead of .T.? 1

Status
Not open for further replies.

KoenPiller

Programmer
Apr 4, 2001
270
NL
Hi,

I have this cursor to populate a grid :

CREATE CURSOR myCursor ( positive L, name c(10))

APPE FROM myTable

Would like the gridfield "positive" to show "Yes" if .T. and obviously "No" if .F.

Also user should be able to change this from Yes to No or vicacersa.

Thought of using a combobox with 2 possibilty only but fail to achieve this, anybody around to give me advice?

Thanks,

Koen

 
Hello,

Have you already tried the iif function.

for example iif(table.a,"yes","no")

FILIP MERLIER
 
Koen,

There are two possible approaches.

First, you could use a character field in your cursor rather than a logical:

SELECT IIF(Positive,"Yes",No ") AS cPositive FROM MyTable ;
INTO CURSOR MyCursor

and then proceed as before.

Alternatively, you could keep your existing cursor, but add two labels to the relevant grid column. Call them lblYes and LblNo. Set the captions to "Yes" and "N"o respectively.

Then, in the grid's Init:

THIS.Column1.DynamicCurrentControl = ;
'IIF(MyCursor.Positive, "lblYes", "lblno")'

You might also need to set the columns Sparse property to .F.

Give it a try.

Mike




Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I normally assign "Y" to the InputMask property in such case. But then, it can only display "Y" or "N"...not "Yes" or "No". Maybe I'm not as picky as I should. ;-)
 
Hi,

Thanks all, difficult to decide which one is the best for me to use, believe I will go for Mike.

Koen
 
Create a YesNo() function and pass the field or value as a parameter. You can also check for values of 0 or greater this way (zero = "No" and 1 or more = "Yes").
 
Hi. Quick Note for future reference...

medic advised: <<I normally assign "Y" to the InputMask property in such case. But then, it can only display "Y" or "N"...not "Yes" or "No".>>

If you try the Y/N input mask and find that it doesn't always work, it is because you need to apply the InputMask to the logical EditBox instead of the grid Column.

This might be obvious to everyone else but took me a while to realise when I tried it for the first few times.
 
Mabey this is not quite what you are looking for but if you use TRANSFORM(myCursor.positive,Y), it Converts logical true (.T.) and false (.F.) values to Y and N, respectively.
Not "Yes", and "No", but "Y", and "N".
 
Hi,
I have opted for the solution of Mike Lewis, this one works as a charm.
Thank you Mike,

Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top