Jump to content

Recommended Posts

Hi There

I am using (or trying to use) FDMemTables and it is not cooperating.  I am using the Community edition of Delphi 10.3 with Windows 10.  I have a DataModule in which I have placed the respective FDMemTables and in the OnCreate event I have put the Field Definitions and create the table as below:

 

with fdmAdmin.FieldDefs do begin       // fdmAdmin
      clear;
      Add('ID',ftString,4);
      Add('Num',ftString,4);
      Add('SaveLocation',ftString,80);
      Add('LastPurchOrder',ftString,30);
      Add('LastInvoice',ftString,30);
      Add('LastReceipt',ftString,30);
      Add('CurrentJournal',ftString,30);
   end;
   fdmAdmin.CreateDataSet;

 

In another Unit (which references the DataModule1 in its Implementation Uses) if have the following code:

 

DataModule1.fdmAdmin.Active := true;
if DataModule1.fdmAdmin.RecordCount < 1 then begin   // if no records means starting and no saving previously done
      DataModule1.fdmAdmin.Append;
      DataModule1.fdmAdmin.Edit;
      DataModule1.fdmAdmin['LastInvoice'] := '0000';
      DataModule1.fdmAdmin['LastPurchOrder'] := '0000';
      DataModule1.fdmAdmin['LastReceipt'] := '0000';
      DataModule1.fdmAdmin.Post;
end;

 

I get the message 'Cannot open dataset [TFDMemTable].  A DataTable or a DataView must be supplied.  Hint:  if this is a TFDMemTable, use CreateDataSet or CloneCursor to open dataset.'

There is a CreateDataSet in the DataModule1 code.  Anyone point me in the right direction here?  Thanks heaps.

Himie

Share this post


Link to post

Hi @Himie

 

Have you sorted this out already? Just out of curiosity I tested the code above in a FMX project, and it worked just fine - Delphi 10.4.2 Enterprise, Windows 10. I really can't tell why it wouldn't work in 10.3 Community ( but I'm no Delphi guru 🙂 ).

Share this post


Link to post

Hi Carlos

Thank you for your response.  I'm no Delphi Guru either, just plug away and spend a lot of time trying to get it to work.

I have worked around the issue it seems that something was not working properly with the DataModule part of the program where it was not going right through the code section of that module.  I spent weeks endeavouring to get it to work and finally had to put all the FDMemTables onto a form and use the code section of the form to define and create the tables (instead of using the DataModule).  It then worked fine.

Cheers

Himie

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×