sjn78 Posted May 26, 2003 Posted May 26, 2003 This has got me puzzled. I have a combobox on the a parent form which has mdi children. The combo is used sort of like a filter. EG, 2000, 2001. The idea of it is to limit the records to only show the ones in the year selected. When I change the year, I want all of the mdi children that are open to call a predetermined function on their own form to run through and select records for that year only. I can run through each open window ok, but when it comes to calling the function, it tells me there is no object. This is what I have so far. This function is on the main form where the combobox is. Function SeasonPick(ByVal sea As String) Dim win As Form showseason = sea For Each win In Me.MdiChildren If win.Name = "FrmManageContacts" Then win.Focus() ' I want to be able to do the following.....its not right though. win.TreePopulate(showseason) End If Next The TreePopulate is the function on the FrmManageContacts form. I have made this function Public. If anyone could help out, it would be great. Steve Quote
ailzaj Posted May 26, 2003 Posted May 26, 2003 Have you tried putting the function in a module? ailzaj Quote
APaule Posted May 26, 2003 Posted May 26, 2003 Fiorst of all, you cann't access a function of a form from anywhere outside the form. So do like ailzaj suggested. Wrap that function in a Module or Class. Did I get it right, that you want to get the year from a combobox on the MDI-Parent? Quote
*Experts* mutant Posted May 26, 2003 *Experts* Posted May 26, 2003 (edited) Cast your win variable to the form you need. Something like this: Dim win as Form For Each win in Me.Controls if win.Name = SomeName1 then DirectCast(win, SomeName1).TreePopulate(showseason) elseif win.Name = SomeName2 then DirectCast(win, SomeName2).SomeMethod End If next This will allow you to acces form class specific methods and things like that. Edited May 26, 2003 by mutant Quote
*Experts* Bucky Posted May 26, 2003 *Experts* Posted May 26, 2003 Fiorst of all, you cann't access a function of a form from anywhere outside the form. This is incorrect. If the function or method (or variable, constant or anything else) is declared as Public, it can be accesed through any instance of the form. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Moderators Robby Posted May 26, 2003 Moderators Posted May 26, 2003 Also, using Modules in .NET is not considered good coding. Quote Visit...Bassic Software
sjn78 Posted May 27, 2003 Author Posted May 27, 2003 Thanks for the suggestions, I will try it out and let you know how I went. Steve Quote
sjn78 Posted May 27, 2003 Author Posted May 27, 2003 I got it to work as per Mutant's suggestion. Thanks Mutant. I don't know what I would do without these forums!!! Steve Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.