>>>I have option buttons on my form class. Depending on the value stored on the table for the option button, I either need to show or hide a text box.
>>>
>>>Example:
>>>if optionbutton.value=1, then show text box,
>>>otherwise, hide text box.
>>>
>>>As the form shows a record, where do I put the code to either show or hide the text box?
>>>
>>>As the user clicks on a 'NEXT' button to go to the next record in the table, form should reflect the record's optionbutton.value & the form should refresh (?) with either the text box shown or not.
>>>
>>>I tried to put the code in the form's REFRESH(), but did not work:
>>>IF THISFORM.optionbutton.VALUE=1
>>> THISFORM.textbox.VISIBLE=.T.
>>>ELSE
>>> THISFORM.textbox.VISIBLE=.F.
>>>ENDIF
>>>
>>>Can anybody help?
>>>THANKS ALL!
>
>>Inge,
>
>>Are you sure that the NEXT button does a refresh ?
>
>>if yes, try the following in the form's refresh
>
>>=DoDefault() && must get new values first, then test will function
>>THISFORM.textbox.VISIBLE = (THISFORM.optionbutton.VALUE=1)
>>NODEFAULT
>>Gregory
>
>THANKS! The =DoDefault() seems to do the trick, although I cannot figure out (or find out) what =DoDefault & NODEFAULT actually do?
Inge,
vfp is a strange animal.
If you put code in a Refresh() method, the code is executed and when you leave the piece of code an implied refresh() is done, ie get the values from disk and put them in the corresponding controls.value.
In your case, you were testing on values that did not belong to the new record, since the refresh-from-disk was done AFTER your tests.
The =DoDefault() forces the refresh-from-disk and gives you the values relevant to your tests.
As to the NODEFAULT: this inhibits the implied refresh() after leaving the method code.
Not having that in is harmless. The refresh() is done twice, once with =DoDefault() and once after leaving the method code.
It serves a purpose though. Form.Refresh() can take a long time (suppose a grid with a lot of columns with Sparce = FALSE).
Since the refesh() was done with the =DoDefault(), we avoid another refresh using the NODEFAULT
Does this make (more) sense ?
(have not read the article Nadya's refering to, but I take it that it says the same)
Gregory