EAccessViolation

When referring to another unit in a Delphi 4 app I get the following error...

Project SysAdmin.exe raised exception class EAccessViolation with message 'Access violation at address 0046C332 in module 'SysAdmin.exe'. Read of address 000002F0...'

This happens when a unit called 'frmBoxName' refers to a unit called 'frmDeleter' like this...

with frmDeleter do
     if gridDeleter.RowCount > 0 then
        btnOK.Enabled := True
     else
        btnOK.Enabled := False;
Release;

The error occurs on the first 'if' statement. If I comment out this entire procedure the same error occurs next time I refer to frmDeleter.

In fact, I get the error whenever any of my forms refer to any of the others...

Both frmDeleter and frmBoxName are included in each other's relevant uses clause.

I'm sure this is really easy, because I'm sure I've done it before successfully and I've done something really daft this time...
riccohbAsked:
Who is Participating?
 
fvaConnect With a Mentor Commented:
Any chance you forgot to create the actual instance of TfrmDeleter into frmDeleter variable? Or that by the time you use frmDeleter the creation is not done yet?

Other idea: Any DLL involved in this?

F.
0
 
MadshiCommented:
Yes, fva is right, I guess your frmDeleter variable is "nil".

Regards, Madshi.
0
 
FrodoBegginsCommented:
Or maybe the form is freed ...

Rgds,
Frodo

0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
riccohbAuthor Commented:
There you go - I told you it was a stupid mistake. I've just added

var frmDeleter: Tfrmdeleter;

to that procedure and it worked perfectly. Thanks.
0
 
YodaMageCommented:
I think fva is right on. Either you are trying to work with forms that have not been created, or with forms that haved already been freed/destroyed.
0
 
YodaMageCommented:
DOH!
0
All Courses

From novice to tech pro — start learning today.