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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optionbutton to return character field

Status
Not open for further replies.

VFP602

Programmer
Jan 23, 2002
41
MP
Hi guys! I created a form wherein an optiongroup button is bound to a character field. I only have two optionbuttons under that optiongroup and either button if clicked, should
return either 'AL' or 'SL' value and not a 1 or 0. Obviously, I'm getting a data type mismatch
message on this. How do I forced the optionbutton to return a char value instead of 0 or 1?
Any help is very much appreciated.
 
VFP602,

Depend on how you prefer to use the resulting value, you will need two character field in your table in addition to one numeric field for the option group. Assuming you have text boxes for the resulting value in your form, a simple code in the InteractiveChangeEvent of your OptionGroup may look like:

if this.value = 0
thisform.TxAL.Value = 'AL'
else
thisform.TxSL.Value = 'SL'
endif

Peping
 
HI VFP602,

You told that the option group is bounded with Character field. So follow the below.

Make the value property of one option button as 'AL' and other option button as 'SL' in the option group. And make the option group value property as either one of your value.

Hope the above only make easy your problem.


Suggestions Invited...

gchandrujs [sunshine]


 
gchandrujs,

Option is numeric and set it with character value will result invalid.

Peping
 
Peping,

Yes, you're right. The reason I posted this question is that I want to find out how to force the optionbutton to take a char. as return value wherein fact, the default value is either 1 or 0. Putting two textboxes to receive the values is a work around. I was thinking of using combo box instead and use one of the cols. to receive the value.
But still I'm curious about forcing the values of the optionbutton since it is much preferred in my form rather than a combo box. I'm not sure if gchandrujs understands my question.
 
vfp602,

you can put this very short workaround to the optiongroup's valid event property:

mystrval = iif(this.value = 1, "SL", "AL")

let me know if this helped.

torturedmind [trooper]
 
vfp602,

you could also use the ffg. command:

mystrval = this.caption

this will work only if the captions of the options 1 and 2 are "SL" and "AL" respectively and that you have put this command in the valid events of both options.

torturedmind [trooper]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top