Invalid argument problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.
I have a DB with a table that contains about 1.5 million records. I'm
creating a routine that computes each record and stores the values on
different tables.

This routine works very well, but at a certain time, i get an error message.
The error is "Run-time error 3001. Invalid argument".
This error occurs always on the same kind of instruction, that is
"RS.Update", and it occurs always on different records.

Can anyone give me a hint why this happen?

Thanks

Luis
 
my guess is that you may need to use NZ or test for null before making
an assignment or constructing a string...

from Help

'~~~~~~~~~~~~~~~~~~~~~~~~~~``
Nz Function

You can use the Nz function to return zero, a zero-length string ("
"), or another specified value when a Variant is Null. For example, you
can use this function to convert a Null value to another value and
prevent it from propagating through an expression.

Syntax

Nz(variant[, valueifnull])

The Nz function has the following arguments.

Argument

variant
A variable of data type Variant.

valueifnull
Optional (unless used in a query).
A Variant that supplies a value to be returned if the variant
argument is Null. This argument enables you to return a value other than
zero or a zero-length string.

Note If you use the Nz function in an expression in a query without
using the valueifnull argument, the results will be a zero-length string
in the fields that contain null values.


'~~~~~~~~~~~~~~~~~~~~~~~~~~``

the thing to keep in mind when using Nz is what it will return if you
don't the specify the second, optional, argument.

If you are using Nz on a field, it will be the data type of that field
-- 0 for numbers (including dates), and an empty string for text or memo

Unbound textbox / combobox / listbox controls on a form are assumed to
have TEXT in them... so an empty string will be returned if nothing is
specified. And, if you specify something, it doesn't have to be 0 or ""

you could do this:

NZ(<expression>,"no commision is found in the table for this employee")

If you do not specify the optional argument -->
If the expression is bound to a text field, an empty string will be
returned if the field is null. If the expression is bound to a numeric
field, 0 will be returned if the field is null.

it is a good idea to wrap return values from dLookup, etc, in NZ in case
no match was found

.... a good "rule-of-thumb" is to specify the optional arguments (even
though it is not necessary) ...

= Nz(DLookup("[Commission]", "Employees", "[EmpID] = " & nz([EmpID],0)),0 )

notice how NZ is used twice -- once to make sure the criteria will be
evaluated, and another time around everything in case dLookup didn't
return a value...




Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
This could be a because of a number of things, probably a bit of data that
doesn't 'fit' the computation (or a null value). Try debugging by:

1. Insert the lines RS.Update followed by an RS.Edit at various points in
the coding. This will enable you to narrow it down to where the coding is
corrupting.
2. You could also put a 'counter' in the loop - e.g. an incrementing (n+1)
variable. When the routine falls over, hover over 'n' and see which record
caused the problem - couple this with 1. above and you should get the answer.

Good luck..

BW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top