Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox with when clause issues
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01058638
Message ID:
01058758
Views:
13
Rodd

This sounds like the old joke:
(PATIENT) Doctor, doctor, it hurts when I do this.
(DOCTOR) Well don't do that then.

I'm confused as to why you have the code in the .When of the combo. You've said that without it the entry stays in. The returning of .F. or .T. determines whether the cbo gets the focus or not. But, as you're already in it, and have entered a value, shouldn't you be testing whether the value is in the other cbo AFTER you entered it, e.g. in the .Valid or ..InteractiveChange?

Hell, I don't think I've hardly ever used the when event - managed totally without it, and I've never been happy with its usefulness (or indeed the Help explanation of it)

???

Terry

>Okay, I've simplified it down some. I made a test form using VFP base classes. The form has a combobox and a textbox. The combobox is set up pretty much like the one below.
>
>If I do not include code in the Where() event, the combobox allows me to enter new text (that does not appear in the drop down list), tab to the textbox and tab back into the combo box without loosing the text that I entered in the combobox initially.
>
>If I add ANY code into the Where() event, and follow the same steps above, when I tab back into the combo box from the textbox, the text that I entered in the combo box is wiped out.
>
>This seems to be default VFP behaviour but why? Why should I loose the text I entered merely because I have a Where() clause?
>
>Are other people running into this? Any ideas on how to get around this behaviour?
>
>Thanks for your help!
>
>Rodd
>
>>Hello Terry,
>>
>>No, the code that I'm placing in the .Where() event is supposed to be there. In other words, I defnitely want it to do that check before allowing the user access to the State/Province combo box.
>>
>>I may have added confusion by listing the code in the .Where() event. It really is irrelavent other than the fact that if I put any code in the .Where() event, the control starts the odd behaviour of wiping out the text the user has entered (if they exit the combobox and reenter it).
>>
>>Is that any clearer?
>>
>>Rodd
>>
>>>Rodd
>>>
>>>Can't really get my head round this. You sure the code shouldn't be in the .Valid() event, if you're reacting to user's input?
>>>
>>>Terry
>>>
>>>>I have a combo box with the following settings:
>>>>
>>>>.ControlSource = thisform.oAddrInfo.stprov
>>>>.Sorted = .T.
>>>>.Name = cboStProv
>>>>.Style = 0
>>>>.RowSource = "nwizprov.stprov"          && Table with alias of nwizprov
>>>>.RowSourceType = 6
>>>>.Format = '!'
>>>>.BoundColumn = 1
>>>>.ColumnCount = 1
>>>>
>>>>
>>>>This allows the user to add provinces into the table if they don't exist in our list. This part works great.
>>>>
>>>>However, if I add the following clause to the When method:
>>>>
return empty(this.parent.cboAddrId.Value)
>>>>I start getting this weird result. If the user enters something into cboStProv that does not exist in the list and then leaves the cboStProv control, when the user re-enters that control, the text they've entered gets wiped out.
>>>>
>>>>If I remove the when clause, the text they entered remains there.
>>>>
>>>>Any ideas as to what is going on and how to fix this? I need the when clause but I need the text to stay there as well.
>>>>
>>>>P.S. I do not add the text they entered to the list until they're done with that form.
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform