Results 1 to 6 of 6

Thread: Feed the object = click on the object ?! Should I believe that??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Hi, everybody!

    There's something strange when I open my form! I could realize that VB is running a module that I've put in a option button click event, but I'm not clicking this button, I only open my form!

    In the form activate event, I feed this button with a table field, by setting its value = true for the Optionbutton(0) or optionbutton(1), depends on the table field.

    Can this be equal to a click on the button?
    Is that way VB works?
    How can I both keep the module which feeds the option button running on form activate event and avoid VB of running the option button on click event?

    Thanks for any idea!
    Roselene

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I just tested it and it does act like a click. In your case, I'd set a public variable in the declarations portion of your form.

    public booClicked as boolean

    then just before you feed the button from the table, set booClicked to false and then just before you leave that code, set it to true.

    Then in the option buttons click event, put the code you have inside an if statement:

    if booClicked = true then

    end if

    This should stop your problem.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Net Surfer,

    Thanks, again !!!!
    You really makes me happy with your useful answers!
    :-)

    Roselene


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Martin,

    Thanks very much for your attention!
    When you say " add a Property on Form2 named, for example, Label1Caption", is it the same them add a variable?
    I'm really learning a lot from all of you.

    Regards,
    Roselene


  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    I'm not completely sure what you are asking, but try this.
    - Bring up the code for a form
    - Go to Tools>Add Procedure (this is for VB6, other VBs may be different)
    - Type in Label1Caption and select the "Property" Type
    - Then modify the Let and Get methods that are created for you to look like this
    Code:
    Option Explicit
    Private g_MyCaption As String
    
    Public Property Get Label1Caption() As String
    
        Label1Caption = g_MyCaption
    
    End Property
    
    Public Property Let Label1Caption(ByVal sCaption As String)
    
            g_MyCaption = sCaption
    
    End Property
    - You'll also need to add the variable g_MyCaption.

    If you have more questions about properties, email me.

    ------------------
    Marty
    Can you buy an entire chess set in a pawn shop?

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Another thing you should know is that anytime you change some visible property of a control, the form that contains that control will be loaded. For example if in Form1 you say Form2.Label1.Caption = "Hi", Form2's Load event will be triggered along with any code that stems from the Load event. A good technique to prevent this from happening is to add a Property on Form2 named, for example, Label1Caption. Then in Form1 you would say Form2.Label1Caption = "Hi" (which will not load Form2). Then in Form2's Load event you would add Label1.Caption = Label1Caption, and whenever you want to load Form2, you can.

    ------------------
    Marty
    Can you buy an entire chess set in a pawn shop?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width