"The variable is not a record. 'Variable.Field'...

So strange… I’m designing a report with 3 dataitems. Nothing unusual. All three dataitems are linked and indented. In the OnAfterGetRecord of the third dataitem I have a line: message(“First DataItem”.“No.”); When I compile I get the error: "The variable is not a record. ‘Variable.Field’ is invalid. The line message(“Second DataItem”.“No.”); doesn’t give an error. DataItemLinkReference and DataItemLink I’ve checked and are working fine. I haven’t got a clue what I’m doing wrong… Does the error I get, ring a bell at someone?

You’ve probably defined another variable with the same name, which isn’t a recordvariable. Try making a piece of code like this MyRecord.“No.” := ‘1’; where MyRecord is a variable of type Decimal and you’ll get that errormessage.

quote:

MyRecord.“No.” := ‘1’;
Originally posted by Steffen Voel - 2005 Dec 15 : 13:31:29

Indeed this does give the same error.

quote:

You’ve probably defined another variable with the same name, which isn’t a recordvariable.

I made a .txt export of the report and searched for the description of the dataitem. Found nothing… Now, to not get angrier, I changed the name of the dataitem (property DataItemVarName) and it now works! Thanks for you help!

Tino, Did you use the table name as a field name in your table?

THis is where the Navision style guide comes in, and why its important. Its why we have variables such as “item No.” and not Item. etc. If you read the guide and follow it, you can avoid these issues. Item = table Item.“No.” = the itme number referenced in table “item” “Item No.” = reference to the field item no in a table other than Item. The style guide is really the FIRST book that you shoudl read in starting Navision, but most people think of it as just defining form sizes etc. Where as it original purpose was to define programming practices that lead to less errors.

Absolutely agree.[^] Always look at the way Navision does things/names things before making your own ‘standards’…

No, not suggesting Tino was creating his own, just pointing him to the right book. The guide is on the CD, and is a good thing to print and have handy when you are programming.

quote:

not suggesting Tino was creating his own,
Originally posted by David Singleton - 2005 Dec 15 : 14:57:00

Me neither. Just seen this to much…

I think that the problem is that I’ve defined the table name of the first dataitem as a field in the third dataitem. [:(!] Forgot the “no.”-addition in the fieldname. Stupid me! All right, learned something again! [:D] David, the Navision style guide; do you mean w1w1term.pdf? For using a local variable type record in code, I define it as lrecRecord. Is there a document for these kind of notations?

Yes, and its a pretty quick read. Once read, print out the pages about field and table naming and keep them handy when programming.

Thanks David. For using a local variable type record in code, I define it as lrecRecord. Is there a document for these kind of notations? Perhaps anyone else knows such a document?