>In thread #
544693 New C0000005 error on VFP 7 I explained it.
>This program re-builds a grid by calling constantly grid init() event.
>I posted init event code. A many of people can reproduces this error but Mike Stewart from Microsoft says that he is unable to reproduce this error.
>
I have a similar issue with grids and init's. When you requery a view that's used in the grid, in the grid's INIT(), you also get a C5 error. This is reproducable for me every time (in both VFP6 and VFP7) with the following code:
Just paste the code into a prg and run it. When it comes up, clicking the Rebuild Grid builds a grid, and clicking it again removes it and rebuilds it. But the 2nd time, the view that's displayed in the grid is requeried, and you will get a C5 error. I'm going to report this to Microsoft as a bug. If Mike Stewart (?) would like to take a look at it and reply here, that would be great.
** START CODE **
public junk
Junk = createobject('oJunkForm')
Junk.Name = 'Junk'
=CREATEOBJECT('CmdQuit')
=CREATEOBJECT('CmdRebuildGrid')
=CREATEOBJECT('CmdRequeryView')
Junk.Addobject('CmdQuit', 'CmdQuit')
Junk.AddObject('CmdRebuildGrid','CmdRebuildGrid')
Junk.AddObject('CmdRequeryView','CmdRequeryView')
Junk.Show()
read events
**----------------------------------------------------------------------------DEFINE CLASS oJunkForm AS Form
Height = 350
Width = 600
FUNCTION LOAD
CLOSE DATA ALL
OPEN DATA 'c:\vfp\samples\tastrade\data\tastrade'
SET DATA TO TasTrade
ENDFUNC
ENDDEFINE
**----------------------------------------------------------------------------
DEFINE CLASS CmdQuit AS CommandButton
Caption = 'Quit'
Left = 300
Top = 300
Visible = .T.
FUNCTION Click
THISFORM.RELEASE()
CLEAR EVENTS
ENDFUNC
ENDDEFINE
**----------------------------------------------------------------------------
DEFINE CLASS CmdRebuildGrid AS CommandButton
Caption = 'Rebuild Grid'
Left = 200
Top = 300
Visible = .T.
FUNCTION Click
=RebuildGrid()
ENDFUNC
ENDDEFINE
**----------------------------------------------------------------------------
DEFINE CLASS CmdRequeryView AS CommandButton
Caption = 'Requery View'
Left = 100
Top = 300
Visible = .T.
FUNCTION Click
=RequeryView()
ENDFUNC
ENDDEFINE
**----------------------------------------------------------------------------
**----------------------------------------------------------------------------
Function RequeryView()
=requery('Customers')
ENDFUNC
**----------------------------------------------------------------------------
**----------------------------------------------------------------------------
FUNCTION RebuildGrid()
if type('junk.ogrid')='O'
Junk.removeobject('ogrid')
release ogrid
endif
createobject('ogrid')
Junk.Addobject('oGrid','ogrid')
ENDFUNC
**-----------------------------------------------------------------------
**-----------------------------------------------------------------------
DEFINE CLASS oGrid as grid
** SETTING PROPERTIES
RecordSource = "Customers"
Visible = .T.
Width = 500
** DEFINING FUNCTIONS
FUNCTION INIT
SET DATA TO TasTrade
IF NOT USED("Customers")
USE 'Customer Listing' IN 0 ALIAS Customers
ELSE
=REQUERY("Customers")
ENDIF
SELECT Customers
ENDDEFINE
**-----------------------------------------------------------------------------
--
Cathy Ciciulla Neppel
Tenaska Marketing Ventures
Omaha, NE