Link to home
Start Free TrialLog in
Avatar of Scrpn
Scrpn

asked on

Application error: Exception EAccessViolation

The delphi code complies fine. whereas on running the application, I get an error which is as follows:
Debugger Exception Notification: Project raised exception class EAccessViolation with message 'AccessViolation at address 005C73F4 in module ---.exe'

On running it again at this point..i get the application error as: Exception EAccessViolation in module ---.exe at 001C73F4. Access Violation at address 005C73F4 in module --.exe

How do i fix this problem?
 
The code is as follows: (it is defined in datamodule MainDMod and uses forms fmMain and fmReports)

procedure TMainDMod.tbPactiveAfterScroll(DataSet: TDataSet);
begin
   if  tbPactive.bof and  tbPactive.eof then fmMain.edPactive.text := '' else fmMain.edPactive.text := 'P';    //Error in this line
end;

and also for:

procedure  TMainDMod.ReportsSourceDataChange(Sender: TObject;
  Field: TField);
begin
    if ReportsReportID.Value <> 26 then begin
    fmReports.lbActionCode.Visible := False;    //error in this line
    fmReports.wlcActionCode.Visible := False;
  end;
......

Please Help!!!
Thanks
Avatar of VGR
VGR

by correcting your code 8-)

you have a Nil pointer somewhere, probably.

Do one of the following :

1) run your program in the IDE and wait for the exception to raise, then note what, where and when

2) show us your code
try put lines for the error lines like this:
if not assigned(tbPactive)  then showmessage('error tbActive');

but it can not show all problems becouse delphi has bug , I mean in some cases it has declaration and no create it can have a value
for example :
var registry:Tregistry;
begin
if not assigned(registry) then showmessage('error');
//Registry:=TRegistry.Create;
Registry.RootKey:=HKEY_LOCAL_MACHINE;
...
it will cause error and it not shows error.
, and cannot know if it initialized or not.you must check if the other forms exists and not freed, try to activate the forms before running this procedure (put temporary fmReports.show), check if the objects not only created in some procedure.
sorry boy, but ***my*** Delphi doesn't raise any exception and doesn't need a TRegistry.Create() !

Declaring the variable is enough !
at least, not for setting only the RootKey ;-)
I mean it is only an example.....
and by me it raises ....d7 enterpise :-((
and I do not know why the delphi development not exchange all free metods with freeandnil.....

 
and when I declare it global (next form1) it is nil and showmessage executed.... ???.....???.....
local variables are taken from the stack... that's the only relevant difference I see
and why not nil?
ASKER CERTIFIED SOLUTION
Avatar of andyprokofiev
andyprokofiev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial