Link to home
Start Free TrialLog in
Avatar of Paulette
Paulette

asked on

@dbLookup field ... value is a constant '1' ??

Have a form with three fields....Requested By <ReqBy>, Requested by Phone <ReqbyPhone> and Requested by Division <ReqbyDiv>.  The Requested by field is a dialog list, editable, choose from Address book dialog.  The Requested by Phone and Division are to be populated dependant upon the choice made in the Requested by field....using an @dbLookup formula...
@If(ReqBy !="")  ;

lkupVal := @dblookup("Notes":""; "123.nsf"; "People"; ReqBy; 2);
Field ReqbyPhone := @word(lkupVal;"Y";1);
Field ReqbyDiv := @word(lkupVal;"Y";2);
@Success;

So when I test the form, the fields ReqbyPhone and Division show the value '1' and are not changable.  These two fields are text /computed...

What have I done wrong now?

help :)  thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

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 zvonko
zvonko

Hello Paulette,

you omitted the server name right hand to the DatabaseName name ("123.nsf"), that is all.

Here a working version:
FIELD ReqBy:=ReqBy;
@If(ReqBy="";@Return(ReqBy);"");

lkupVal := @DbLookup("Notes":""; "":"123.nsf"; "People"; ReqBy; 2);
@If(@IsError(lkupVal);@Return(ReqBy);"");
FIELD ReqbyPhone := @Left(lkupVal;"Y");
FIELD ReqbyDiv := @Right(lkupVal;"Y");
ReqBy

Regards,
zvonko

PS: Also would be good another value for the separator character, perhaps pipe char: |

PS.PS: Also does @Success give a hint you use InputValidation of the ReqBy field for populating ReqbyPhone and ReqbyDiv field.
Better place for the lookup formula would be the InputTranslation event of the ReqBy field.


Avatar of Paulette

ASKER

Hemanth

The field I am creating, is it a separate field from my Requested by field?  A hidden field maybe?

thanks in advance
I think what Hemanth is trying to say is the following :
Set in your dialog field <ReqBy> the property "Refresh fields on keyword change" on the second tab of the field properties.
This will automatically refresh other fields when you make a selection from the dialog list.

Then your other two fields should be computed for display with the formula's Hemanth suggested, or you can use the formula's as provided by zvonko.
He's right, you need to specify both server and database name to open the database. If the database is on local, the server is "", otherwise you need to specify the server name. If this is a lookup in the current database you can use @DbName.

An example:
lkupVal:=@DbLookup("Notes":"NoCache"; "servername":"123.nsf"; "People"; ReqBy; 2);

or if you are looking in the current database:
lkupVal:=@DbLookup("Notes":"NoCache"; @DbName; "People"; ReqBy; 2);

Hope this helps,
JM
Yes Paulette, lkupval will be hidden field . Sorry I din't notice that the dblookup was missing server parameter. Should be a typo I suppose.