How to make a form truely private?

A newbie question:

I have a form which I have set it to private datasession. The form has an object which is based on a class: cboacct.
This class is a container class which has a cbo and a text box. The cbo takes an acct# and seeks the customer file.

Originally the ControSource for the cbo was simply 'acct' and being blobal, it worked fine.
I'm trying to use a protected property instead. I have created a protected class property named 'acct'.
I've changed the Controlsource in the cbo to this.parent.acct and I'm not sure what I'm doing wrong (Among many things) but I'm getting an error that property acct could not be found...

I hope I make myself clear... Any ideas

Thanks,
A.


Answer this question

How to make a form truely private?

  • Cathal Connolly

    Hi Aleniko

    Protected properties are only visible to the class (or object) that creates them, and their descendents. So making a form property 'protected' also makes it invisible to any object on the form. Properties are bound to their owning object anyway, and so are 'private' to them and the main reason for making a property protected is to prevent it from being accessed by other objects - hardly what you want in this case.

    But my question is why does the textbox even need a controlsource If the purpose of the combo is to populate the name, based on the account number, then surely the textbox belongs in the container with the combo. Then all you need to do is have the combo call a method on the container from it's valid that will do the search and set the Value of the textbox. (Since the container is the parent of both the combo and the textbox this is fine). All the code then lives in the container class and is nicely encapsulated. 

  • Tummaluru

    Hi Aleniko,

    You've got a form and on the form is a container. The container holds a TextBox and a ComboBox. Is your property on the Form, Container, or ComboBox Where is the code that accesses the property and exactly what is the line of code



  • lucindrea

    Cindy;

    Sorry if I sound like a real newbie...

    I have a class named cboacct. The class has a container, and the members are a cbo and a textbox. All I am trying to do is to collect an acct # at the cbo, and display the name at the texxt box.
    Right now I have done that by putting this into the valid of the cbo:

    SELECT custmr
    SEEK macct
    thisform.cname=custmr.name
    thisform.Refresh()

    The cbo's controlsource is macct (Which is public by definition)

    The textbox has it's control name as thisform.cname

    Now, I know how ugly this whole thing is, and I also know it's not good oop practice. I can't figure out how to do this without using a property at the form level.

    Do I put in the cbo's valid
    this.parent.txtname.value=custmr.name
    What do I use as the controlsource for the text box

    I want this to be a black box so it can be used everywhere...

    Thanks,
    Aleniko


  • How to make a form truely private?