From: Ringo on
In my table. I set many key in this table and I use mytable.get('abc') that
alway to get frist key record for me.
Somebody can tell me that how to use the second or third ... key to get the
record.

From: Ian C on
Hi Ringo,

Use SETCURRENTKEY and either SETRANGE or SETFILTER depending on your
situation...

e.g.,

Item.SETCURRENTKEY("Vendor Item No.","Vendor No.");
Item.SETRANGE("Vendor Item No.",'ABC');
Item.SETRANGE("Vendor No.",'123');
IF Item.FINDFIRST THEN REPEAT
//
// do something
//
UNTIL Item.NEXT = 0;

--
My NAV Blog
http://www.nextequalzero.com

Follow me on Twitter
http://twitter.com/NextEqualZero


"Ringo" wrote:

> In my table. I set many key in this table and I use mytable.get('abc') that
> alway to get frist key record for me.
> Somebody can tell me that how to use the second or third ... key to get the
> record.
>
From: Duikmeester on
{QUOTE}
FINDFIRST: You should only use this function when you explicitly want to
find the first record in a table or set. Do NOT use this function in
combination with REPEAT..UNTIL.
{/QUOTE}

"Ian C" wrote:

> Hi Ringo,
>
> Use SETCURRENTKEY and either SETRANGE or SETFILTER depending on your
> situation...
>
> e.g.,
>
> Item.SETCURRENTKEY("Vendor Item No.","Vendor No.");
> Item.SETRANGE("Vendor Item No.",'ABC');
> Item.SETRANGE("Vendor No.",'123');
> IF Item.FINDFIRST THEN REPEAT
> //
> // do something
> //
> UNTIL Item.NEXT = 0;
>
> --
> My NAV Blog
> http://www.nextequalzero.com
>
> Follow me on Twitter
> http://twitter.com/NextEqualZero
>
>
> "Ringo" wrote:
>
> > In my table. I set many key in this table and I use mytable.get('abc') that
> > alway to get frist key record for me.
> > Somebody can tell me that how to use the second or third ... key to get the
> > record.
> >
From: Ian C on
Quite true :)

--
My NAV Blog
http://www.nextequalzero.com

Dynamics NAV Search Engine
http://j.mp/iNAVigate

Follow me on Twitter
http://twitter.com/NextEqualZero


"Duikmeester" wrote:

> {QUOTE}
> FINDFIRST: You should only use this function when you explicitly want to
> find the first record in a table or set. Do NOT use this function in
> combination with REPEAT..UNTIL.
> {/QUOTE}
>
> "Ian C" wrote:
>
> > Hi Ringo,
> >
> > Use SETCURRENTKEY and either SETRANGE or SETFILTER depending on your
> > situation...
> >
> > e.g.,
> >
> > Item.SETCURRENTKEY("Vendor Item No.","Vendor No.");
> > Item.SETRANGE("Vendor Item No.",'ABC');
> > Item.SETRANGE("Vendor No.",'123');
> > IF Item.FINDFIRST THEN REPEAT
> > //
> > // do something
> > //
> > UNTIL Item.NEXT = 0;
> >
> > --
> > My NAV Blog
> > http://www.nextequalzero.com
> >
> > Follow me on Twitter
> > http://twitter.com/NextEqualZero
> >
> >
> > "Ringo" wrote:
> >
> > > In my table. I set many key in this table and I use mytable.get('abc') that
> > > alway to get frist key record for me.
> > > Somebody can tell me that how to use the second or third ... key to get the
> > > record.
> > >
From: Boriau Kristiaan on
Hi

The Get() function only works upon the first key PK

When one needs to select a secondary key one has to use the
SETCURRENTKEY,SETRANGE,SETFIKLTER

IF one has a long list of Ranges and filters to I suggest you create a
functio upon the table.

exp.

MyGet()
Parameters
VAR theTBL : datatype Record
keyNo : datatype Integer
pramCode :datatype Code
pramDate :datatype Date
etx..
for every needed type generate a variable pram.......
etx.

Code within the the function

WITH theTBL DO BEGIN
CASE keyNo OF
1:
BEGIN
//PK
END;
2:
BEGIN
//2de key
SETCURRENTKEY("field1',"field2,"field3" ....... "filedn");
SETRANGE("field1", pramCode);
SETFILTER("field2", '%1.. %2', pramDate, WORKDATE);
IF FINDFIRST THEN
EXIT
ELSE
ERROR(GETLASTERRORTEXT);
END;
3:
BEGIN
//3de key
END;
.
.
.
n:
BEGIN
//n key
END;
ELSE
BEGIN
// if keyNo is outside the given range
ERRROR('key outside the given range');
END;
END:
END;


Like I said this is an example code and an ideea how to solve yor prob.
Gtrz


"Ringo" <Ringo(a)discussions.microsoft.com> schreef in bericht
news:98F20819-A7A6-4747-9E69-4F21BE01F768(a)microsoft.com...
> In my table. I set many key in this table and I use mytable.get('abc')
> that
> alway to get frist key record for me.
> Somebody can tell me that how to use the second or third ... key to get
> the
> record.
>