RecordRef / FieldRef

DesmedtSDesmedtS Member Posts: 53
edited 2003-11-28 in Navision Attain
Hello,

I wrote ethe following code :

RecRef : RecordRef
FldRef : FieldRef

RecRef.OPEN(27);
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');
RecRef.FIND('-');
FOR i := 1 TO RecRef.FIELDCOUNT DO BEGIN
FldRef := RecRef.FIELDINDEX(i);
CASE FldRef.NAME OF // Or you can use a case on FldRef.NUMBER
'description': MESSAGE('%1 is2.',FldRef.CAPTION,FldRef.VALUE);
'Unit Cost': MESSAGE('%1 is %2.',FldRef.CAPTION,FldRef.VALUE);
END;
END;

The following problem is this line of code :
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');

The SETRANGE is a value that filters only on field no.

The above code is in a loop so (repeat of a setup table), for example
the first time i loop, I want to filter on Item no.
the second time, i want to filter on unit cost. of a specific item where my record is positioned at.

The table No. and the field no. is in a setup table of which value a have to get.

How can i make this variable ?

So for further example :

I have the right record and then i look in my setup table where there is always a table No. and a Field No., and

FldRef := RecRef.FIELD(xxx); // xxx must be the field no. of the
table which is in the setup table
FldRef.SETRANGE('xxx'); // xxx lust ve the value of the table
No. and the field No.


Thx a lot

Steve

Comments

  • eromeineromein Member Posts: 589
    Steve,

    did you take a look at my record ref sample?

    http://www.mibuso.com/dlinfo.asp?FileID=276

    Maybe the answer is in there somewhere?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • eromeineromein Member Posts: 589
    btw,

    You will need a table inwhich you store table and field nos.
    filter.setrange(tableno, 27);
    if not filter.find('-') then
      exit;
    
    repeat
      fieldref := recref.field(filter.field);
      fieldref.setrange(filter.filtervalue);
    until filter.next = 0;
    
    if not fieldref.find('-') then
      exit;
    
    message('a record was found!');
    
    
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
Sign In or Register to comment.