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: Errors Caused by Strong Typing in Microsoft Access 2000


View products that this article applies to.

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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

↑ Back to the top


Symptoms

In Microsoft Access 2000, you may receive one of the following error messages when you try to set or use some form and report properties in your database:
Run-time error '13':

Type mismatch
-or-
Run-time error '94':

Invalid use of Null
NOTE: The same action that causes the error message in Access 2000 may not produce an error in earlier versions of Access.

↑ Back to the top


Cause

Some properties that returned values of the Variant data type in earlier versions of Microsoft Access are strictly typed as non-Variant data types in Microsoft Access 2000.

↑ Back to the top


Resolution

Verify that no errors exist in your application by doing the following:
  • Compile and save all modules in your database. To compile your database and its modules, follow these steps:
    1. In the Database window, click Modules.
    2. On the View menu, click Code.
    3. On the Debug menu, click Compile MyDatabase. If this option is not available, it means that your database is already compiled and the modules have been saved.
  • Check for run-time errors when you run your code.

↑ Back to the top


More information

Some form and report properties that returned Variant values in earlier versions of Microsoft Access now return strict data types. The term for this is strong typing or strict typing. Visual Basic for Applications code in your database that includes strictly typed properties runs faster in Access 2000. However, when you convert a database from an earlier version of Access to Access 2000, you must verify that no errors are introduced in your application by the new data types.

The following are lists of properties that returned Variant values in earlier versions of Microsoft Access, but which return specific data types in Access 2000.

Properties Returning String Data Types

   AfterDelConfirm      InputMask        OnGotFocus     OnRetreat
   AfterInsert          Item             OnInsert       OnTimer
   AfterUpdate          MenuBar          OnKeyDown      OnUnload
   BeforeDelConfirm     OLEClass         OnKeyPress     OnUpdated
   BeforeInsert         OnActivate       OnKeyUp        OrderBy
   BeforeUpdate         OnApplyFilter    OnLoad         Picture
   Caption              OnChange         OnLostFocus    RecordSource
   Class                OnClick          OnMenu         RowSource
   ColumnWidths         OnClose          OnMouseDown    RowSourceType
   ControlName          OnCurrent        OnMouseMove    ShortcutMenuBar
   ControlSource        OnDblClick       OnMouseUp      SourceDoc
   ControlTipText       OnDeactivate     OnNoData       SourceItem
   DatasheetFontName    OnDelete         OnNotInList    SourceObject
   DefaultValue         OnEnter          OnOpen         StatusBarText
   Filter               OnError          OnPage         Tag
   Format               OnExit           OnPrint        ValidationRule
   FormName             OnFilter         OnPush         ValidationText
   HelpFile             OnFormat         OnResize
				

Properties Returning Boolean Data Types

   AddColon     Dirty
   AutoLabel    HideDuplicates
   Cancel       RepeatSection
				

Properties Returning Double Data Types

   CurrentX       ScaleLeft
   CurrentY       ScaleTop
   ScaleHeight    ScaleWidth
				

Properties Returning Integer Data Types

   DatasheetGridlinesBehavior    FillStyle     OLETypeAllowed
   DrawMode                      LabelAlign    RunningSum
   DrawStyle                     LabelX        ScaleMode
   DrawWidth                     LabelY
				

Properties Returning Long Data Types

   BackColor            DatasheetBackColor         FillColor
   BorderColor          DatasheetForeColor         ForeColor
   CurrentRecord        DatasheetGridlinesColor
				

Steps to Reproduce Behavior

The following example demonstrates the error message that you receive if you try to set the ControlSource property of a text box control to Null in Access 2000. The ControlSource property is typed as a String data type in Access 2000; you receive an error because String data types cannot contain Null values.
  1. Start Microsoft Access 2000 and open the sample database Northwind.mdb.
  2. Open the Customers form in Design view.
  3. Add a command button with the following properties to the form:
    Command button
    Name: CommandStrict
  4. Set the OnClick property of the command button to the following event procedure:
    Private Sub CommandStrict_Click()
       Me![CompanyName].ControlSource = NULL
    End Sub
    					
  5. On the View menu, click Form View, and then click the CommandStrict button. Note that you receive the following error message:
    Run-time error '13':

    Type mismatch

↑ Back to the top


References

For more information about strong or strict typing, click Microsoft Access Help on the Help menu, type i'm getting a type mismatch message in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about data types, click Microsoft Access Help on the Help menu, type type property in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For additional information about strong typing and other issues related to converting databases from earlier versions of Microsoft Access, click the article number below to view the article in the Microsoft Knowledge Base:
237313� ACC2000: Conversion White Paper Available in Download Center

↑ Back to the top


Keywords: KB202352, kbprb

↑ Back to the top

Article Info
Article ID : 202352
Revision : 2
Created on : 6/29/2004
Published on : 6/29/2004
Exists online : False
Views : 363