Multiple Forms Question: Object reference not set to an instance of an object 
Author Message
 Multiple Forms Question: Object reference not set to an instance of an object

Hello. I am working on a program that will be able to have several of the
same form (frmLogs). I developed the form to run by itself, and it worked
great. Now, I added a 'Sub New' and tried to call it from another form
(frmSwitchboard), but I keep getting errors.

----------------------------------

Here is what I have in frmLogs:

    Dim mdblJobNo As Double

    [Windows Form Designer generated code]

    Sub New(ByVal JobNo As Double)

        mdblJobNo = JobNo

    End Sub

Here is what I have in frmSwitchboard:

    Dim f As New frmLogs(cmbJobID.SelectedValue)

    f.Show()

------------------------

Almost every line of code will break and say 'Object reference not set to an
instance of an object.' For example, this line breaks:

Me.SelCmdHoles.Parameters.Item("pJobNo").Value = mdblJobNo

Is there something I am missing? Do I need to refer to the particular
instance of the form somehow?

Thanks,

Joe



Tue, 06 Dec 2005 05:06:00 GMT  
 Multiple Forms Question: Object reference not set to an instance of an object
Try changing your sub new to the following.

    Sub New(ByVal JobNo As Double)

        MyBase.New()

        mdblJobNo = JobNo

    End Sub

Quote:
>-----Original Message-----
>Hello. I am working on a program that will be able to
have several of the
>same form (frmLogs). I developed the form to run by

itself, and it worked
Quote:
>great. Now, I added a 'Sub New' and tried to call it
from another form
>(frmSwitchboard), but I keep getting errors.

>----------------------------------

>Here is what I have in frmLogs:

>    Dim mdblJobNo As Double

>    [Windows Form Designer generated code]

>    Sub New(ByVal JobNo As Double)

>        mdblJobNo = JobNo

>    End Sub

>Here is what I have in frmSwitchboard:

>    Dim f As New frmLogs(cmbJobID.SelectedValue)

>    f.Show()

>------------------------

>Almost every line of code will break and say 'Object

reference not set to an

- Show quoted text -

Quote:
>instance of an object.' For example, this line breaks:

>Me.SelCmdHoles.Parameters.Item("pJobNo").Value =
mdblJobNo

>Is there something I am missing? Do I need to refer to
the particular
>instance of the form somehow?

>Thanks,

>Joe

>.



Tue, 06 Dec 2005 08:01:30 GMT  
 Multiple Forms Question: Object reference not set to an instance of an object
Thank you very much for your help!
-Joe


Quote:
> Try changing your sub new to the following.

>     Sub New(ByVal JobNo As Double)

>         MyBase.New()

>         mdblJobNo = JobNo

>     End Sub

> >-----Original Message-----
> >Hello. I am working on a program that will be able to
> have several of the
> >same form (frmLogs). I developed the form to run by
> itself, and it worked
> >great. Now, I added a 'Sub New' and tried to call it
> from another form
> >(frmSwitchboard), but I keep getting errors.

> >----------------------------------

> >Here is what I have in frmLogs:

> >    Dim mdblJobNo As Double

> >    [Windows Form Designer generated code]

> >    Sub New(ByVal JobNo As Double)

> >        mdblJobNo = JobNo

> >    End Sub

> >Here is what I have in frmSwitchboard:

> >    Dim f As New frmLogs(cmbJobID.SelectedValue)

> >    f.Show()

> >------------------------

> >Almost every line of code will break and say 'Object
> reference not set to an
> >instance of an object.' For example, this line breaks:

> >Me.SelCmdHoles.Parameters.Item("pJobNo").Value =
> mdblJobNo

> >Is there something I am missing? Do I need to refer to
> the particular
> >instance of the form somehow?

> >Thanks,

> >Joe

> >.



Sat, 10 Dec 2005 23:32:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error when showing form: Object reference not set to an instance of an object

2. Object reference not set to an instance of an object

3. Object Reference Not Set to an Instance of an Object

4. Please help with error: Object reference not set to an instance of an object

5. How to fix Error: Object reference not set to an instance of an object

6. Object reference not set to the instance of an object

7. Object reference not set to an instance of an object

8. Object reference not set to an instance of an object

9. Object reference not set to an instance of an object

10. New Twist on: Object reference not set to an instance of an object

11. Object reference not set to an instance of an object

12. Error: Object reference not set to an instance of an object

 

 
Powered by phpBB® Forum Software