If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Problem updating very basic data on my 'Base Form'

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-10, 05:50
Hamsori Hamsori is offline
Registered User
 
Join Date: Nov 2010
Posts: 20
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....
Reply With Quote
  #2 (permalink)  
Old 12-14-10, 05:53
Hamsori Hamsori is offline
Registered User
 
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...
Reply With Quote
  #3 (permalink)  
Old 12-14-10, 11:32
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #4 (permalink)  
Old 12-15-10, 03:22
Hamsori Hamsori is offline
Registered User
 
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...
Reply With Quote
  #5 (permalink)  
Old 12-16-10, 15:34
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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.
__________________
oh yeah... documentation... I have heard of that.

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

Last edited by Teddy; 12-16-10 at 15:39.
Reply With Quote
  #6 (permalink)  
Old 12-20-10, 08:54
Hamsori Hamsori is offline
Registered User
 
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!
Reply With Quote
  #7 (permalink)  
Old 12-24-10, 11:05
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
Reply

Tags
base, button, form, inherit, label

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On