Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disabling controls
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Visual ProMatrix
Miscellaneous
Thread ID:
00509330
Message ID:
00509424
Views:
15
Farouk,

In the Load event of your form, after you open your tables, check the structure, if the field exists in a table. If not, put corresponding control ControlSource to "" and set it to be invisible (visible=.f.) It actually could be make generic by checking each control in Form.Controls collection and checking its ControlSource against table structure...

Oops, just thought: we can't access Form's objects in Form.Load, and Form.Init would be too late...




>Hi!
>
>There are a lot of solutions for this, but neither is good:
>- Make an error handler that ignores the error that occurs when form loads and control source for some control do not exists.
>- Make a cursor in the Load event using CREATE CURSOR command. Include all fields required in this cursor. Bind offending fields to this cursor, while all otehr fields will be tied to the existing fields.
>- Just clear control source property of these fields and copy it to the Comment property of the control. This way control will not blow up form, as well as you have the correct information about what source field used in old application for that control.
>
>In addition, there are Enabled and Visible properties to make controls unavailable for editing by users (this do not solve problem with absent fields, but just rules the appearance).
>
>HTH.
>
>>Hi VFP users & gurus
>>
>>I need to be able to disable some data controls such as textboxes to make my application backward compatible. Normally, application will bomb if the field to which the data control is tied to, doesn't exist. Thanks.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform