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.tbPactiveAfterSc roll(DataS et: 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.ReportsSourceDat aChange(Se nder: TObject;
Field: TField);
begin
if ReportsReportID.Value <> 26 then begin
fmReports.lbActionCode.Vis ible := False; //error in this line
fmReports.wlcActionCode.Vi sible := False;
end;
......
Please Help!!!
Thanks
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.tbPactiveAfterSc
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.ReportsSourceDat
Field: TField);
begin
if ReportsReportID.Value <> 26 then begin
fmReports.lbActionCode.Vis
fmReports.wlcActionCode.Vi
end;
......
Please Help!!!
Thanks
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.Crea te;
Registry.RootKey:=HKEY_LOC AL_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.
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.Crea
Registry.RootKey:=HKEY_LOC
...
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 !
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 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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