SetRange/FindFirst VS Get to find a record

samantha73samantha73 Member Posts: 106
Hi
To find a record using the primary key we can use setrange/findfirst or Get. What are the differences between these two patterns? Does get throw an error if the primary key not found while findfirst in setrange will not error?
Thanks

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    If you do FindFirst or Get without error handling (if not FindFirst/Get), then both will throw errors.
    When you know entire primary key, it's usually better to do Get for performance.
    However! If you intend to pass the record into a report, then use SetRange on PK fields as report datasets operate on filtered records - using Get and passing it to a report will make the report run on entire table as if it wasn't filtered.
Sign In or Register to comment.