lotus notes, search data that equal to textbox

怎甘沉沦 提交于 2019-12-12 01:59:49

问题


I don't understand why my code is not allowed.

@If(@DbLookup("":"nocache";@DbName;"GPA";1)="GPnum";@Failure(@Command([FileSave])&@Command([CloseWindow]));@Success)`

Please help me. Thank you.


回答1:


@If(@DbLookup("":"nocache";@DbName;"GPA";1)="GPnum"

your code should have 1 more parameter.

from help

@DbLookup( class : cache ; server : database ; view ; key ; fieldName ; keywords )

So you have "GPA" as view and then you need to specify Key and field/column you wish to return. Also for DbLookup I would recommend you to use [FAILSILENT] as keywords, in this case you will not need to check result for @IsError

However probably you just need to use @DbColumn instead of @DbLookup.

as I understood you need to verify if some value exists in database/view, try this code:

@If(@DbColumn("":"NoCache";@DbName;"GPA";1)="GPnum"; @Failure(@Command([FileSave]) : @Command([CloseWindow])); @Success)

or

@If(@DbLookup("":"NoCache";@DbName;"GPA"; "GPnum"; 1; [FAILSILENT])<>""; @Failure(@Command([FileSave]) : @Command([CloseWindow])); @Success)



回答2:


Edit: I add a code for button action that save the current doc (see author comment below)
The editable field in which the user enters the value we check is called GPnum. A view "GPA" is sorted by its first col an display GPnum value.

t:=@DbLookup("":"nocache";@DbName;"GPA"; GPnum ; 1 ; [FailSilent] );
@If(@IsError(t) ; @Prompt([Ok]; "DB has a problem:";@Text(t)) ;
  t = "" ; @Do(@Command([FileSave]);@Command([CloseWindow])) ;
  @Prompt([Ok] ; "unable to save" ; "The key already exists") )

original response

t:=@DbLookup("":"nocache";@DbName;"GPA"; @ThisValue ; 1 );
@If(@IsError(t) ; @Failure("DB has a problem:"+@Text(t)) ; t =  "" ; @Success ; @Failure("The key already exists") )

If you use @failure/@success you MUST be in an editable field in a form (validation). As I understand you check that your value does not ALREADY exists. so:

first add @thisValue as the key you search in the DBLOOKUP, as told above DBLOOKUP could return an error thus check @isError(t)
second failure just BLOCK the validation of the form, I never tried (an it doesn't make sense) to make it save the form

Hope it helps



来源:https://stackoverflow.com/questions/13524206/lotus-notes-search-data-that-equal-to-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!