Unloading Form from Within DBGrid Event Causes GPF (142839)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
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
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kbDatabase KB142839 |
---|
|