Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: "Invalid Use of Null" Error When You Try to Add a Record to a Form in NorthwindCS.adp


View products that this article applies to.

This article was previously published under Q221343
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access project (.adp).

↑ Back to the top


Symptoms

When you try to assign the value of a control to some other object in a Microsoft Access project, you may receive the following error message:
Invalid use of Null

↑ Back to the top


Resolution

Use the IsNull function to verify the control's value before you assign the value to some other object. To see an example of how to do so, follow these steps. This example uses the Suppliers form in the sample project NorthwindCS.adp.
  1. Open the Suppliers form in Design view.
  2. View the OnCurrent property setting of the form, and note that it has [Event Procedure].
  3. Click the Build (...) button next to the OnCurrent property box to open the Private Sub Form_Current() event procedure.

    The line of code that causes the error is:
    strLinkCriteria = "SupplierID = " + CStr(Forms![Suppliers]![SupplierID])
    					
  4. Place this line of code within a conditional statements. For example:
    If Not IsNull(Forms![Suppliers]![SupplierID]) Then
       strLinkCriteria = "SupplierID = " + CStr(Forms![Suppliers]![SupplierID])
    End If
    					
  5. Compile the code, close the Visual Basic Editor, and view the Suppliers form in Form view.
  6. Add a new record and note that the error message no longer occurs.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in Microsoft Access 2000.

↑ Back to the top


More information

This symptom is specific to Access 2000 projects. However this same error may occur whenever you use Visual Basic for Applications (VBA) code in Access.

It is common, for example, to use VBA code to reference controls on a form and to assign the values returned (by the reference) to some other object, such as a variable. If the control on the form contains a Null value, and the code attempts to assign this value to a String variable for example, you receive the error message described in the "Symptoms" section.

Steps to Reproduce the Behavior

  1. Open the sample database NorthwindCS.adp.
  2. Open the Suppliers form in Form view.
  3. On the Edit menu, point to Go To, and then click New Record. Note that you receive the error message mentioned in the "Symptoms" section.

↑ Back to the top


References

For more information about the IsNull function, click Microsoft Visual Basic Help on the Help menu, type IsNull in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB221343, accesscs, kbpending, kbclientserver, kbdta, kbbug

↑ Back to the top

Article Info
Article ID : 221343
Revision : 1
Created on : 12/12/2002
Published on : 12/12/2002
Exists online : False
Views : 339