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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Use of Null + Expression too Complex

Status
Not open for further replies.

pkw25

MIS
Mar 20, 2002
46
IE

Hello

I'm running an access query to output customer values for invoicing to a file. As part of the process we have to produce Modulus 11 checkdigits aswell. I'm using an access module for this. I'm getting the following error's

Run-time error'94'
Invalid use of null

here's the code with the line repeated at the end which appears to causing the problem.

ublic Function anpostocr(CheckDigit)
'--checkdigit$ = Command$

Dim checkarray(40)
Dim weight(40)

'If Format([CheckDigit]) = "0000.00" Then
'CheckDigit = (CheckDigit * 100)



CheckDigitST = Str(CheckDigit)

lent = Len(CheckDigitST) '--get lenght of string

For I = 0 To (lent - 1) '--split up string digit by digit & put in array
checkarray(I + 2) = Val(Mid$(CheckDigitST, (lent - I), 1))
Next I

For I = 2 To lent + 1 '--calculate the weights for each digit
weight(I) = (checkarray(I) * I)
sum = sum + weight(I)
Next I
'--sum now holds value we need
CheckDigit = 11 - (sum Mod 11)
If CheckDigit >= 10 Then CheckDigit = CheckDigit - 10 '---for case of 10 or 11
checkarray(1) = CheckDigit '--add the checkdigit to the

'-- for debug only-- Print " CheckDigit is > "; CheckDigit

For I = (lent + 1) To 1 Step -1 '--go through the array backwards & rebuild string with check digit attached
checkout$ = checkout$ + LTrim$(Str$(checkarray(I)))
Next I

CheckDigit = checkout$
anpostocr = checkout$

'--Print checkout$
End Function

For I = 0 To (lent - 1) '--split up string digit by


I'm also getting the following error

"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables
."

The strange thing about this problem is that it dosen't happen al the time.

Any help would appreciated on this matter.

Paraic.
 
if you have 2000 or above

try the split fuction to create your array.

it may make it a bit easier
it may work
 

Thanks for your reply

I can't use split beacuse it uses a delimiter and my string dosen't have one that I can see. It's of the form 12587 There are no spaces or other delimiting characters.

Rgds

Paraic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top