Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access violation. Why?

0 views
Skip to first unread message

Mario Furió

unread,
Sep 12, 2000, 10:32:46 AM9/12/00
to
Hello new.

When I start my applycation I create my own tables. But when I do this in On
Create event of my principal form it raises an exception and tell me Access
violation read of address XXXXXXXX & xXXXXXXX. I'm little lost with this
error. I know it raises an Access violation when a table has the same record
various times but the tables that I create are still empty. Somebody could
help me?

Thanks a lot.

Mario.


M.H. Avegaart

unread,
Sep 12, 2000, 11:00:48 AM9/12/00
to
In the OnCreate of your main form the other forms/datamodules are not yet
created, so you can't use them.


"Mario Furió" <mari...@teleline.es> schreef in bericht
news:8pleju$3jc...@SGI3651ef0.iddeo.es...

Mario Furió

unread,
Sep 13, 2000, 2:01:27 AM9/13/00
to

M.H. Avegaart escribió en mensaje <8plgf4$j05$1...@porthos.nl.uu.net>...

>In the OnCreate of your main form the other forms/datamodules are not yet
>created, so you can't use them.


Ok, and wich event can I use to create them?


Smola

unread,
Sep 13, 2000, 3:00:00 AM9/13/00
to
"Mario Furió" <mari...@teleline.es> wrote:

I use OnShow.

Smola
--
...and then you read this.

(use "supersmola@" to reply)
(http://www.katedrala.com/ass}

Ray Porter

unread,
Sep 13, 2000, 8:15:45 AM9/13/00
to
If you're using a datamodule that you are allowing Delphi to autocreate,
move its instantiation to a position before the main form's creation in your
DPR file. You can use code something like this:

begin
hWnd := FindWindow('TApplication', 'Reunion Tracking');
if hWnd = 0 then
begin
Application.Initialize;
Application.Title := 'Program Tracking';
Application.CreateForm(TdbModule, dbModule);
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end
else
begin
if IsIconic(hWnd) then
ShowWindow(hWnd, SW_RESTORE);
SetForegroundWindow(hWnd);
end;
end.

The key thing here for your purposes is that call to
Application.CreateForm(TdbModule, dbModule) comes before
Application.CreateForm(TMainForm, MainForm).

If you're not allowing Delphi to autocreate your datamodule, just make sure
you instantiate the datamodule before you attempt to use any of its
components. You can also get an access violation if you attempt to access
any of the controls (edit boxes, etc) on your mainform form the its OnCreate
event.

The important thing to remember is that any objects you reference, must be
created before you reference them.


--
================================================
Ray Porter
Applications Analyst Programmer
Administrative Information Services, UNC-CH
Phone: 966-5878
email: ray_p...@unc.edu
dra...@email.unc.edu
Home Page: http://www.unc.edu/~dragon/

"Meddle not in the affairs of dragons,
for thou art crunchy and taste good with ketchup."


"Mario Furió" <mari...@teleline.es> wrote in message
news:8pn4uu$49...@SGI3651ef0.iddeo.es...

M.H. Avegaart

unread,
Sep 13, 2000, 11:59:02 AM9/13/00
to
Use:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

const
wm_AfterCreate = wm_User;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure WMAfterCreate(var Message: TMessage); message wm_AfterCreate;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
PostMessage(Handle, wm_AfterCreate, 0, 0);
end;

procedure TForm1.WMAfterCreate(var Message: TMessage);
begin
// now all forms are created
end;

end.


"Mario Furió" <mari...@teleline.es> schreef in bericht

news:8pn4uu$49...@SGI3651ef0.iddeo.es...

Robert Kaplan

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
It would be nice to have something like "On After Create", to initialize a
form. I use OnActivate with a tacky switch to prevent the code from being
executed on subsequent activations of the form.

Smola <A...@inet.hr> wrote in message news:39bfc3a5...@news.iskon.hr...

M.H. Avegaart

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
You CAN make a real OnAfterCreate (see my answer from yesterday).


"Robert Kaplan" <rka...@iamerica.net> schreef in bericht
news:R34w5.297$wn2....@dca1-nnrp2.news.digex.net...


> It would be nice to have something like "On After Create", to initialize a
> form. I use OnActivate with a tacky switch to prevent the code from being
> executed on subsequent activations of the form.
>
> Smola <A...@inet.hr> wrote in message
news:39bfc3a5...@news.iskon.hr...
> > "Mario Furió" <mari...@teleline.es> wrote:
> >
> > >

0 new messages