Table Number from the Record

Hello All, Would like some help in the follow please? I have a record call recPurchaseHeader (Which we all know is Table 38) How can I get this Table Number? Regards Graham.

Try this function: GetTableID(TableName : Text[250]) TableID : Integer Object.SETRANGE(Typ,Object.Typ::Table); Object.SETRANGE(Mandantenname,COMPANYNAME); Object.SETRANGE(Name,TableName); IF Object.FIND(’-’) THEN EXIT(Object.ID) ELSE BEGIN Object.SETRANGE(Mandantenname); IF Object.FIND(’-’) THEN EXIT(Object.ID) ELSE EXIT(0); END; Object is a variable of type record, refering to the virtual table “object”. Since you would not use the german version, the field names of the object table will not be the same, but this should not be a problem to you.

Thx Alex, Got your example to work in Swelish (Swedish/English) version as well. Thx Onces again

You do not need the SETRANGE on Companyname, since objects are stored without company in the Object table. The first FIND statement is obsolete.

Two more options are: TableNo := DATABASE::"Purchase Header"; or RecRef.GETTABLE(recPurchaseHeader); TableNo := RecRef.NUMBER;

Hello Fritz This was more like it, a true example of KISS programing. I was trying TableNo := DATABASE::recPurchaseHeader.TABLENAME; But Compler did not like this. Regards

You have to write DATABASE::“Purchase Header”, do not use your varable-name for this. The other way around is to use RecordRef, as Fritz mentioned.