Passing a form to a sub in a module 
Author Message
 Passing a form to a sub in a module

I have 3 forms that each have a clientlist combobox. Before these forms are
shown, the combobox is filled with my clientlist.

The code for each is exactly the same so I have created a sub FillClientList
in a module and made it public

My problem is, how do I pass the form that the combobox is on to this
routine?

I tried Sub FillClientList (ByVal frm as Form)
frm.cboClient.items.add ... etc

frm.cboClient is underlined and tells me the cboClient is not a part of
System.Windows.Forms.Form

Sorry, I'm too new at this to understand what I need to do

Thanks

Charlie



Fri, 23 Sep 2005 04:40:58 GMT  
 Passing a form to a sub in a module
How do you spawn each form?  probably something like this,
Dim formvar1 as new form1 (or whatever your formname is)
dim formvar2 as new form2
dim formvar3 as new form3

then you can open them like so,
formvar2.showdialog(me)
that will spawn that form, now when you close that form or whatever, you can
reference that combobox from your main form like this

formvar2.cboClient

I "hope" this make sense.  if you need anymore help just lemme know, I am
new to this too, but I am learning pretty well.

good luck


Quote:
> I have 3 forms that each have a clientlist combobox. Before these forms
are
> shown, the combobox is filled with my clientlist.

> The code for each is exactly the same so I have created a sub
FillClientList
> in a module and made it public

> My problem is, how do I pass the form that the combobox is on to this
> routine?

> I tried Sub FillClientList (ByVal frm as Form)
> frm.cboClient.items.add ... etc

> frm.cboClient is underlined and tells me the cboClient is not a part of
> System.Windows.Forms.Form

> Sorry, I'm too new at this to understand what I need to do

> Thanks

> Charlie



Fri, 23 Sep 2005 05:23:11 GMT  
 Passing a form to a sub in a module
Hello Charles,


Quote:
> The code for each is exactly the same so I have
> created a sub FillClientList in a module and made
> it public

> My problem is, how do I pass the form that the
> combobox is on to this routine?

> I tried Sub FillClientList (ByVal frm as Form)
> frm.cboClient.items.add ... etc

> frm.cboClient is underlined and tells me the cboClient
> is not a part of System.Windows.Forms.Form

Why don't pass the combo box directly?

In the "module":

\\\
Public Sub FillClientList( _
    ByVal cboComboBoxToFill As ComboBox _
)
    .
    .
    .
End Sub
///

In the form:

\\\
modHelpers.FillClientList(Me.cboClients)
///

Regards,
Herfried K. Wagner



Fri, 23 Sep 2005 05:27:48 GMT  
 Passing a form to a sub in a module
Thanks Herfried & Dustin,
Didn't quite understand your method Dustin and plus I didn't mention that
I'm using MDI with Child forms which would be a problem using the
ShowDialog() method. But anyway thanks for the input.

Charlie



Quote:
> Hello Charles,


> > The code for each is exactly the same so I have
> > created a sub FillClientList in a module and made
> > it public

> > My problem is, how do I pass the form that the
> > combobox is on to this routine?

> > I tried Sub FillClientList (ByVal frm as Form)
> > frm.cboClient.items.add ... etc

> > frm.cboClient is underlined and tells me the cboClient
> > is not a part of System.Windows.Forms.Form

> Why don't pass the combo box directly?

> In the "module":

> \\\
> Public Sub FillClientList( _
>     ByVal cboComboBoxToFill As ComboBox _
> )
>     .
>     .
>     .
> End Sub
> ///

> In the form:

> \\\
> modHelpers.FillClientList(Me.cboClients)
> ///

> Regards,
> Herfried K. Wagner



Fri, 23 Sep 2005 08:37:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Passing Value from Module Function to Form sub problem

2. Passing input box value from Form Module to report module

3. Help passing array to bas module sub

4. Pass variable form module to a form

5. How do you pass from obj from one form to a module/forms

6. passing forms and controls so I can set focus back to a form from a module

7. passing forms and controls so I can set focus back to a form from a module

8. Audit Trail Module using sub forms

9. module sub called from within form

10. trying to start a form, from a MAIN sub in a module

11. Calling a Sub in Another Form vs a Module

12. Form, module, class and sub or function names at runtime

 

 
Powered by phpBB® Forum Software