Solved

Object reference not set to an instance of an object

Posted on 2004-08-25
4
186 Views
Last Modified: 2010-04-23
I know why this is happening I just don't know how to fix it.  I have the following code in a class:

Dim frm As New frmStateDTS
frm = frmStateDTS.ActiveForm
frm.Invoke(frm.CallBindStudentData)

In this class, a dataset is being filled from text file.  When the file is imported I call the "callBindDtudentData" method invoker so I can bind the datagrid in my form with the dataset filled in the class.  This operation can take a long time so I may minimize the form and open another window.  When it gets to the line
'frm.Invoke(frm.CallBindStudentData)' I get the following error:

Object reference not set to an instance of an object.

This only happens when the form is not the top window or I have another window (ie web browser) open on top of the form.
0
Comment
Question by:km1039
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898329
what are you trying to do with   "frm = frmStateDTS.ActiveForm"... ?
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898335
you can just use...

Dim frm As New frmStateDTS()
frm.CallBindStudentData()

-Baan
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11898473
that won't work baan ...

the issue is with ...

Dim frm As New frmStateDTS
frm = frmStateDTS.ActiveForm 'its not the active form therefor this is null
frm.Invoke(frm.CallBindStudentData)

there are a few other ways you could do this ... i.e. find the reference to the form you want, baan's method will just create a new form. An answer might be to have your application remember which students form is active in order to run the invoke. You could also just handle this problem by showing an error message in the case that ie etc are in front of your form

if not frm is nothing
else
error
end if
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898522
oh.. ok... I guess..  I understood his question now... he wants to get the active form and call the method in it...
did I really get it ?? :))
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question