procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
with dm3.table1 do
begin
for i:=0 to fieldcount-1 do
begin
combobox1.Items.Add(fields[i].fieldname);
dm3.table1.next;
end;
end;
end;
var i: integer;
begin
with dm3.table1 do
begin
for i:=0 to fieldcount-1 do
begin
combobox1.Items.Add(fields[i].fieldname);
dm3.table1.next;
end;
end;
end;
我看你的form1是主窗体吧,要真的是这样,dm3肯定没有创建
可以吧dpr文件的窗体创建顺序修改一下就行了
var
i: integer;
begin
with dm3.table1 do begin
for i:=0 to fieldcount-1 do
combobox1.Items.Add(fields[i].fieldname);
next;
end; end;
with message 'access violation at address 004ad631 module 'Project1.exe'.
read of address 00000060'. Process stopped. Use Step or Run to continue.
******************************************************
NO1:看一看你的DM3窗体,以前有这种问题,就是不一心将字给打错了;
NO2:
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
with dm3.table1 do begin
for i:=0 to fieldcount-1 do
combobox1.Items.Add(fields[i].fieldname);
end;
end;
+++++++++++++++++++++++++++++++++++
刚一formCreate()时,你就这样写,肯定要出错的;
你试着把这段代码放到一个可视的事件里,如:buttononclick()试一试,结果应该是正确的;
form中,其实我还不是很明白模块和主窗体的先后顺序,要怎么样
把FORM创建顺序调为以下就可以啦.
Application.Initialize;
Application.CreateForm(TDM3, DM3);
Application.CreateForm(TFORM1, FORM1);
Application.Run;
的问题而是窗体先后的问题,因为书上同样的源代码是可以运行的
就可在里面调整顺序就调整了创建的先后顺序
如
Application.Initialize;
Application.CreateForm(TDM3, DM3);
Application.CreateForm(TFORM1, FORM1);
Application.Run;