I am writing a program that uses two modules, a VCL win32 application module and a Datamodule to contain ADO components and a clientdataset to work the data in memory.

When compiling the code fails with the message Raised Exception class EAccessViolation in Module EstimateMngr.exe. The debugger shows failrue in the following code:

procedure TForm3.ResetDataSets;
  //Fails in next line at the IF statement
  IF DataModule3.TaskClientDataSet.Active THEN DataModule3.TaskClientDataSet.Close;
    DataModule3.ADOTaskTable.ConnectionString := AccessCxHelper.CXString;

The DataModule unit is in the uses clause. Tracing the execution shows that once it finishes reading the first line, it jumps to a function VirtualQuery in the Windows unit, then to GetModuleFileName in Windows, and then into the process to raise the exception.

Does anyone have suggestions?

I have an idea... i should work...If you are using Delphi - go to 'Project' - 'Options' - then a menu will appear that shows you your forms, put ALL your forms before your Data module page, they will then run before the data module and your problem is solved, also try this - set all connections to false, then code on your form show event


and on form close