Hi, sorry for my English, that's not my language. I'll try to explain as best as possible.
I'm trying to retrieve a value from current record (Rec), but I need to recover the value of a particular field (this information I get from another table, id field and name field).
I tried to do through RecRef and Field Ref, but I can not position the cursor on the desired record (Rec). I have the feeling that there is an easier way.
I hope I explained well. Any help would be welcome.
Regards.
0
Comments
recRF.OPEN(recObjet.ID,FALSE);
recRF.SETTABLE(Rec);
recRF.FINDFIRST;
fldRef := recRF.FIELD(3); //<---Set the Field Number
MESSAGE(FORMAT(fldRef.VALUE));
When I called from a Card Form (without filters), I am getting data from the first record.
RecObject.ID is the value of the current table.
why do you use recordref and fieldref instead of declaring a table variable and to a simple :?:
moreover, you should use GETPOSITION and SETPOSITION (use NAV online help for more info about these functions) to achieve what you need.
if you do a FINDFIRST without filters like you did, what can you expect?the first record in the table, i guess!
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
I can not create a simple variable, because the table I find out at runtime.
I will investigate the functions and setPosition getPosition (never had used before.)
With FindFirst, I thought that would be placed in the current record, but I was wrong.
Thank you
RecRef.GETTABLE(Record);
FRef := RecRef.FIELD(FieldNo);
There's your FRef.VALUE, no need to FIND the record ...
On a sidenote: FINDFIRST will move to the first record. If you have the PK-Values set (e.g. by SETPOSITION) you can use FIND('=') to fetch the record.
Cheers,
mkb