Unloading Form from Within DBGrid Event Causes GPF
Article ID: 142839
Article Last Modified on 12/9/2003
APPLIES TO
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q142839
SYMPTOMS
When unloading a form from within an event of a Data Bound Grid control a
General Protection fault will occur in VB.EXE or an Exception fault will
occur in VB32.EXE.
CAUSE
The cause of the problem is that the unload event is destroying the
recordset object of the data control. When the DBGrid gets control back the
recordset pointer is no longer valid.
STATUS
Microsoft has confirmed this to be a problem in Visual Basic version 4.0.
We are researching this problem and will post new information here in the
Microsoft Knowledge Base as it becomes available.
WORKAROUND
To work around this problem, add a timer control to the form and allow the
"Unload Me" command to happen here rather than in the DBGrid control. Here
is a step-by-step example to correct the problem:
- Add a timer control to the form. Set its Enabled property to False and
its Interval property to 5.
- In the timer event of the timer control add 2 lines of code:
Timer1.Enabled = False
Unload Me
- In the event of the DBGrid that you wish to unload the form add this
line of code:
Timer1.Enabled = True
Additional query words: 4.00 vb4win vb4all gp-f gpf gp
Keywords: kbdatabase KB142839