Runtime error "Object or Record required to access Method"

Hi,

I'm getting a runtime error "uDatDec: Object or Record required to access Method 'Create'.
in line 'Item := TItemDec.Create();'

uDatDec is a class script that uses uTItemDec class script defined as '{$CLASS TItemDec}'.

Item is declared as 'Item : TItemDec;' -> defined as class in uTItemDec script

when using it in main script works ok.

this works ok in uDatDec class script that uses class TOperacionDec from other class script.

FOperacion := TOperacionDec.Create;

Any hints?

Thanks in Advance,

Omar Zelaya

I have the following code in uTDatDec class script under a Method of TDatDec class:

TDocumento is a a class script
TItemDec ias a class script

Doc := TDocumento.Create(); work ok
Item := TItemDec.Create(); get error "Object or Record...".

Any hints?

Thanks in advance,

Omar Zelaya

Doing some Test.

In tge main begin..end of uTDatDec class script

I add
Doc := TDocumento.Create(); ok;

Item := TItemDec.Create(); I get

image

Thanks in advance,

Omar Zelaya

Hi,

I have added a script to create clases and it work ok the following code in uTDatDec:

Item := CreaTIemDec;

Script that create classes ...

Script code.

uses uTItemDec;

function CreaTIemDec : TItemDec;
begin
Result := TItemDec.Create();
end;

1 Like

Glad you solved it. If you still want to know what happened here, please send a project reproducing the issue, thank you.