Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Violation error when closing a Form

Status
Not open for further replies.

Ingonito

Technical User
Jan 28, 2006
3
Hello.

I have 2 Forms. ChildForm and MainForm. In the MainForm I have Table-component and datasource component and DBGrid.

Ok. In the mainForm I can browse the Access-table.

In the ChildForm I have Query-component and Datasource component and Edit-field where I can write sql-sentences.

Query works fine. BUT when I close this ChildForm I got error:

Code:
Project projekti2.exe raised exception class EAccessViolation with message 'Access violation at address 
40056CB1 in module 'VCL50.BPL'. Read address 0000022c'. 
Process stopped. Use Step to Run to Continue

What causes this error ?

Close button which are in ChildForm are like this:

Code:
Query1->Close();
ChildForm->Close()

 
Try using caFree on the child form's OnClose method.
Code:
void __fastcall TChildForm::FormClose(TObject *Sender, TCloseAction &Action)
{
    Action = caFree;    
}
//---------------------------------------------------------------------------

Also, are you using a bit mapped button (BitBtn) for the child's close button? I discovered that when I use those buttons, and I change the button style to "Close," the button's close method never gets executed. I had to move the code from the button's close method to the form's close method.

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
No. The error still comes.

yes I had BitBtn, but I changed these buttons to the regular buttons.

-Ingonito
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top