@DBlookup item not found in index

Hello

When I use @dblookup in my form used by a button I get an error “item not found in index…”

My code

@Command([EditDocument];“1”);

@Command([ViewRefreshFields]);

lutype := “Notes”:“NoCache”;

ludb := “”:“bkp.nsf”;

luview := “(Klantprojectoverzicht)”;

lucol := 2;

@If(@Begins(@ServerName;“CN=me”);ludb := “me/holding BV”:“BedrijfKlantProject.nsf”;ludb := “”:“BedrijfKlantProject.nsf”);

lookup:=@DbLookup(lutype;ludb;luview;“Intern”;lucol;[FailSilent]);

Lukey := @Prompt([OkCancelList];“Prj”;“Select”;Null;lookup);

FIELD Tr_klantnaam := @DbLookup(lutype;ludb;luview;Lukey;3);

@Command([ViewRefreshFields])

Cape

Subject: @DBlookup item not found in index

there is always a possibility that the key is not found in the view and hence you may get the error above. try catching the error by using @if(@iserror(@dblookup());THEN COND; @dblookup())

Subject: RE: @DBlookup item not found in index

The first dblookup works fine. I get a window (@prompt) with only the records that belongs to the given key.When I select an entry from the list and I display the return value of the @prompt It gives the correct entry but. The second dblookup fails

FIELD Tr_klantnaam := @DbLookup(lutype;ludb;luview;Lukey;3);

Subject: RE: @DBlookup item not found in index

Try this:

a:= @DbLookup(lutype;ludb;luview;Lukey;3);

FIELD Tr_klantnaam := @if( @iserror( a); “”; a);

Subject: Solved: @DBlookup item not found in index

Solved, I used the same view twice. Now I made a second view with in the first column a key.

Thanx for all the input.

Subject: The problem is that the in the view that you are using…

You are retrieving the 2nd column to prompt the users with. When you do a @DbLookup, it is looking for the key to be the first column (“Intern”), not the 2nd. You either need to have another view that is just by ProjectName or modify your view to have the first column combine the “Intern” + “~” + ProjectName, then do a @DbColumn, then prompt the user with @Right(dbColumn; “Intern~”). Then modify your second DbLookup to be “Intern~” + Lukey.

Also, your specification of ludb code could be a little cleaner…

lucol := 2;

ludb := @ServerName : “BedrijfKlantProject.nsf”;

lookup := @DbLookup(lutype;ludb;luview;“Intern”;lucol;[FailSilent]);

Lukey := @Prompt([OkCancelList];“Prj”;“Select”;Null;lookup);

FIELD Tr_klantnaam := @DbLookup(lutype;ludb;luview;Lukey;3);

@Command([ViewRefreshFields])

Subject: RE: The problem is that the in the view that you are using…

The first column of the view is for the key. I dont want all my projects just a subset. (works) The second column in my view is a concatanation of some fields for displaying information to the user, so the user knows which entry to select. (works)

The Third column in my view is for Tr_klantnaam but I have also have a fourth column with information that also have to be stored in a variable. So

FIELD Tr_klantnaam := @DbLookup(lutype;ludb;luview;Lukey;3)

FIELD Tr_info := @DbLookup(lutype;ludb;luview;Lukey;4)

What do i have to change to make it work.

Subject: RE: The problem is that the in the view that you are using…

Solved, I used the same view twice. Now I made a second view with in the first column a key.

Thanx for all the input.