Help: Run-time error '94': Invalid use of Null (1 Viewer)

psimpson

Registered User.
Local time
Today, 14:59
Joined
Aug 1, 2007
Messages
40
There is an existing application which allows new records to be created from a button off the main form. When using this button to add new records the above-noted error is returned. This error is returned when the system attempts to execute the following code:

intCoNo = [Forms]![ProjInfo]![county num]

Here intCoNo is set to zero, but valid values for intCoNo should be between 1 and 92. I am not certain as to why it is being set to zero other than it is for a new record and the value isn't set yet.

Can anyone shed some light on this matter for me please?

Thanks.
 

boblarson

Smeghead
Local time
Today, 14:59
Joined
Jan 12, 2001
Messages
32,059
If there isn't a value in the control on the form, then it is trying to set a numeric to NULL which it can't do. You can use:

intCoNo = Nz([Forms]![ProjInfo]![county num],0)

to keep that from happening, but it will assign 0 to it. You can substitute any value you want instead of 0 if that works better.
 

Users who are viewing this thread

Top Bottom