Typemismatch error with a simple dblookup

Hi I get an error in this code that I cannot figure out…

Store = “ABC”

LastStoreNum =Evaluate(|@Subset(@DbLookup(“”:“NoCache”;“”;“AllNumbers”;“| & Store & |” ;2);1)|)

If LastStoreNum= "" Then

	NextNumber = 1

Else

	NextNumber = Cint(LastStoreNum(0)) + 1

End If

the problem that I get is a error with the first time the store is created in the database… First time around there is nothing, so I added the if statement If LastStoreNum= “” Then so the first time it works but the second time around I get a type mismatch and vise versa if I dont put the if statement, I get an error in this line NextNumber = Cint(LastStoreNum(0)) + 1.

how could I accomodate the first time the field LastStoreNum being empty and the second time having 1 as a value in the variable LastStoreNum

thanks

A.

Subject: typemismatch error with a simple dblookup

First, an Evaluate returns a Variant array, so the return is going to be an array even if there’s only a single value. You can’t compare an array directly to a string or add a number to an array in LotusScript.

Dim evalReturn As Variant

Dim lastStoreNum As Variant 'may be number or string

evalReturn = Evaluate(|…Formula String Here…|)

lastStoreNum = evalReturn(0)

Use the type-checking function IsNumeric before doing any comparisons. Looks like your formula will return a number when there are documents in the category, and text otherwise (since “no value” in Formula Language is an empty string):

If IsNumeric(lastStoreNum) Then

nextNumber = Cint(lastStoreNum) + 1

Else

nextNumber = 1

End If

Subject: RE: typemismatch error with a simple dblookup

thanks Stan for your response…

I am gettting a type mismatch on the Evaluate(LastNum =Evaluate(|@Subset(@DbLookup(“”:“NoCache”;“”;“AllNumbers”;“| & Store & |” ;2);1)|)) statment, I beleive that is caused by the @ subset function.

The first time around it is fine then I get 1 for number,the second time around I get Type Mismatch on the evaluate, then after 3 time + it is ok… I believe that is because the @subset is trying to get a value from the value [1]… and when it is the 3rd time and any other times after that the value is [1,2]

am I making any sense?

Store = "ABC" 

LastStoreNum =Evaluate(LastNum =Evaluate(|@Subset(@DbLookup(“”:“NoCache”;“”;“AllNumbers”;“| & Store & |” ;2);1)|))

If LastStoreNum= “” Then

NextNumber = 1

Else

NextNumber = Cint(LastStoreNum(0)) + 1

End If

A.

Subject: typemismatch error with a simple dblookup

I think you need to be sure that you’ve declared LastStoreNum as a Variant. Also, you need to change this line:If LastStoreNum = “” Then…

to

If LastStoreNum(0) = “” Then…

Good Luck!

Rebecca