Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula logic problem on @dblookup

Status
Not open for further replies.
Sep 2, 2002
32
DE
Hi everyone,

I have a field, that looks up values from a view, but if a value is not included in the view, it gives an Error message. Is their a way I can change this to give a more meaningfull error message. by the way, I do want the users to enter codes which are not in the view. Each time the document is refreshed it goes back to the standard error message. I'm having a problem getting the logic right in the formula.

Any help would be great, thanks.

This code runs in a field called Desc1

@If(StockCode1 !="" ;@DbLookup("";"server":"db.nsf";"myView";StockCode1;2);Desc1)

This script runs on QuerySave

If uidoc.fieldcontains("Desc1","ERROR") Then
Call uidoc.FieldSetText("Desc1","Code not in database.")
End If
 
You need to assign the lookup to a variable directly, before passing the result to the field :

Code:
LkpResult:=@If(StockCode1 !="" ;@DbLookup("";"server":"db.nsf";"myView";StockCode1;2);Desc1);
@if(@iserror(LkpResult);"Code not in database.";LkpResult)[\code]

By doing that, you eliminate the popup message and can control directly in the field the result. That also eliminates the QuerySave code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top