Selecting only the first record from lookup

Hello Everyone,

How could i select only the first record only from a lookup whereas cant access the other records but can view it?

Suppose having 4 lines on the lookup but able to select the first one only.

Thanks in Advance

please describe in more detail what you need.

it’s not clear what you want.

How do you sort the selected/filter records ?

Does User can able to change sorting method by selecting others key (if exist) ?

Try it:

Form/Page - OnQueryCloseForm() : Boolean

Record.SETCURRENTKEY(Field1, [Field2],...)
IF Record.FINDFIRST THEN BEGIN
   RecordVar2 :=Record.
   ......................
   ......................
END;

I am having a lookup field(table relation )in a subform. Now i have multiple lines there. I want that the user can only able to select the first line from that lookup not the other lines.

How could i do so??

Thanks all

Hi,

is there any line number for subForm? If exist, in that case it is possible…

yes, its having line no…So do i need to close the lookup from property & write it through code?

But how to catch only the first line ?

to get only the first record redefine the filter criteria, so that you only get one line as lookup result, add e.g. line no. = 10000.

for writing lookup code follow

https://msdn.microsoft.com/en-us/library/ee414204.aspx

use rec.findfirst to get only the first record of a filtered result or use get function.

Hi,

you can set a filter on the table relation to select only the first line. Go to the table option/Table relation/set the filter between the source table and the destination table based on the line number.

:slight_smile: Have fun coding

hi,

is your question answered ?

yes, thank you all

please verify the answers, which helped you to find a solution. thx.

In on lookup trigger…

after setrange the by the common field the findfirst has worked for me.

IF PAGE.RUNMODAL(50087,pagename)=ACTION::LookupOK THEN

BEGIN

record.RESET;

record.SETRANGE(HpLedger.“Proposal No”,“Proposal No.”);

record.SETRANGE(HpLedger.“I.C No”,“Customer Nos.”);

record.SETRANgE(HpLedger.“Payment Status”,FALSE);

IF record.FINDFIRST THEN

“Line No”:=record.“Entry No”;

“Installment Amount”:= record.“Due Amount”;

“Due Date”:= record.“Due Date”;

END;