Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2010
    Posts
    20

    Unanswered: Problem updating very basic data on my 'Base Form'

    Hi again...

    Getting forward on my program and learning pretty quickly. Now I just have a weird problem...




    Lets say I have a 'Base Form' with a toolbar, Label_1, etc...
    I have also a 'Main Form' which inherits from the 'Base Form'.

    When I push a button in the 'Main Form' that is supposed to write a text for the Label_1 in the 'Base Form', nothing happens...

    -->



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    BaseForm.Label_1.Text = ("JEAAAA")
    End Sub






    I have tried adding:
    BaseForm.Update()
    BaseForm.Validate()

    ...nothing seems to work....

  2. #2
    Join Date
    Nov 2010
    Posts
    20
    Quote Originally Posted by Hamsori View Post

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    BaseForm.Label_1.Text = ("JEAAAA")
    End Sub


    If the label is on the same Form the above code is ok. (Without the "BaseForm.") but when I need to write to another Form, nothing happens...

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I think you might be misunderstanding what inheritance implies...

    Can you walk through your expected behavior and why you chose inheritance in plain terms (no code)?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Nov 2010
    Posts
    20
    I have a base form which I use for the navigation bar, status strip and for showing some information about the current situation. I chose inheritance for the other form because thought that would be the best and easiest way to keep the navigators the same... I will propably make very many forms and also make changes to the navigation bar along the way, so this way the changes would always apply to all forms and their navigators...

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Tell me more about your navigation bar. Do you have on single bar that you want to be displayed across all forms, or do you have multiple forms that have their own copy of your nav bar?

    Also, have on considered going MDI with your "main" form owning the menu and then docking everything else inside the main form? It might make your life easier.


    I don't know exactly what you're doing here, but I can almost guarantee that inheritance isn't going to be the answer. When you inherit from your base form, you're inheriting the type definition of that form, not a reference to an instance of the form. When you call MyBase.SomeMethod(), you're calling a method on your INHERITED form. Again, inheritance does not mean you get to go talk to another form. It means you have identical copies of the methods/properties/fields/etc as whatever you inherited from.
    Last edited by Teddy; 12-16-10 at 16:39.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    Nov 2010
    Posts
    20
    I have a single bar that I want to be displayed for all Forms. (This is why I thought it would be a good idea to use it from my Base Form...)

    Actually I tried the MDI very briefly... I will get back to it if that is the more proper way to make my program.



    ...I actually managed to do what I wanted. I made a Public Sub on my Base Form and in that sub wrote a code that writes the text for that Label. So, if I want to update the information I just call for that Public Sub from any other Form and voilá.
    Anyway, this seemed like a bit of a strech, but I got it to work. I will be looking into the MDI and child form -stuff later on. It may be a lot easier for this.



    Thanks for the answer!

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Yup, I think MDI would make your life easier. Otherwise you might explore improving on your current approach and creating a static/singleton menu controller that all of your forms can call. This controller can contain all the logic necessary to decide what physical bar needs to be updated. It is generally better to loosely couple your forms unless they ABSOLUTELY MUST know about each other.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Tags for this Thread

Posting Permissions

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