Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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?

  • *Experts*
Posted (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 by mutant
  • *Experts*
Posted
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.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

I got it to work as per Mutant's suggestion. Thanks Mutant.

 

I don't know what I would do without these forums!!!

 

Steve

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...