How to fetch table fields from a table

paulobcpaulobc Member Posts: 18
Could someone please tell me how I can fetch the fields from a certain table when I am located inside a function in that same table that I will then call from a form.

If I have table1 with field1, field2, field3

and I want to to get field1 how would I do it?

I could do myvariable := field1; // But am I not missing something here?


Thanks.

Comments

  • garakgarak Member Posts: 3,263
    not really clear what you want. But to get a record from a table you can use the GET() command if you can identify the record by primary key. Or you use setrange() / setfilter if you need a RecordSet.

    example:
    MyTableAsVariable.get(ValueOfPrimaryField1,[ValueOfPrimaryField2,ValueOfPrimaryField3 ...]);
    MyVariable := MyTableAsVariable.SomeField;
    
    //or if you need a REcordSet to go through the recs in a loop
    
    MyTableAsVariable.setrange(AFieldInTheTable,Value);
    if MyTableAsVariable.findset then begin 
      repeat
        //now you go through the recs .......
      until MyTableAsVariable.next = 0;
    end;
    
    Do you make it right, it works too!
  • SavatageSavatage Member Posts: 7,142
    inside a functions I like to specify

    myvariable := item.field1
    (for example)
Sign In or Register to comment.