Link to home
Start Free TrialLog in
Avatar of David Schmalzer
David SchmalzerFlag for United States of America

asked on

Dblookup and unique

I am trying to automatically fill in address fields based on a company name which is generated from a button which has the following formula:

List1 := @Unique(@DbColumn("":"NoCache";"85256f4e:006706e3 "; "Company Lookup"; 1));
Choice := @Prompt([OKCANCELLIST]; "Customer";"Select the Customer"; List1;
List1);

Then (and I will only use 1 address field to save space) I want to fill in the address field. So , this follows the above:

FIELD address := @Unique(@DbLookup("" : "NoCache"; "" ; "Company Lookup"; Choice; 2));
@If(@IsError(address); ""; address);

The problem is that it is still returning 3 or 4 of the same addresses. So, I guess @Unique is not the correct command to use?
Avatar of Andrea Ercolino
Andrea Ercolino

List1 := @Unique(@DbColumn("":"NoCache";"85256f4e:006706e3"; "Company Lookup"; 1));

Choice := @Prompt([OKCANCELLIST]; "Customer";"Select the Customer"; ""; List1 );
@If( Choice = ""; @Return( "" ); "" );

FIELD address := @DbLookup("" : "NoCache"; "" ; "Company Lookup"; Choice; 2);
@If(@IsError(address); ""; address);
ASKER CERTIFIED SOLUTION
Avatar of Bozzie4
Bozzie4
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Schmalzer

ASKER

That's the ticket!  Thanks alot!
Bozzie4> @if(Choice = "";@return(""); Choice = null; @return("");"");
<<Choice = null>> ? :-)

I agree with points to Bozzie... because I forgot the first error check and thought the formula was executing in a computed field!

However I don't think the prompt can return multiple values without [OkCancelListMult]...
So <<@trim(@unique(res2))>> could be simply <<res2>>. And I think <<@trim(@unique(res))>> could be simply <<@unique(res)>> because it's very uncommon that a "Company Lookup" view lists empty companies (and if it does, should be considered an oversight)