I am trying to create a form dynamicly and thus I need to initialize my DBGrid with code.

{ Connect the DBGrid to the database. }
procedure TfrmRemoveRecord.InitDBGrid();
begin
  dbgList.DataSource := dmProgramDatabase.dsrCaches;
end;

But I get an access violation error.

Recommended Answers

All 3 Replies

What is dmProgramDatabase? My guess is that it is a data module and you have not created it before InitDBGrid is called.

No, I have created my data module.

Solved the issue. I needed to call the initialization in the OnActivate and not in the OnCreate of the form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.