ACC97: Errors Caused by Strong Typing in Microsoft Access 97

ID: Q166712


The information in this article applies to:


SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

In Microsoft Access 97, 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 Microsoft Access 97 may not produce an error in earlier versions of Microsoft Access.


CAUSE

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


RESOLUTION

Verify that no errors exist in your application by doing the following:


STATUS

This behavior is by design.


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 Microsoft Access 97; however, when you convert a database from an earlier version of Microsoft Access to Microsoft Access 97, you must verify that no errors are introduced in your application by the new data types.

Following are lists of properties that returned Variant values in earlier versions of Microsoft Access, but return specific data types in Microsoft Access 97.

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 Microsoft Access 97. The ControlSource property is typed as a String data type in Microsoft Access 97; you receive an error because String data types cannot contain Null values.
  1. Start Microsoft Access 97 and open the sample database Northwind.mdb.


  2. Open the Customers form in Design View.


  3. Add a command button to the form:
    
          Command button:
          Name: Command0
          OnClick: [Event Procedure] 



  4. Set the OnClick property of the command button to the following event procedure:
    
          Private Sub Command0_Click()
             Me![CompanyName].ControlSource = NULL
          End Sub 


  5. Switch the Customers form to Form view, and click the Command Button. Note that you receive the following error:
    Run-time error '13': Type mismatch.



REFERENCES

For more information about strict typing, search the Help Index for "Type Mismatch (error message)."

For more information about data types, search the Help Index for "data types, described."

For more information about this and other issues related to converting databases from earlier versions of Microsoft Access, please see the following article in the Microsoft Knowledge Base for instructions on obtaining the Microsoft Access 97 Conversion white paper:

Q151193 ACC97: MS Access 97 Conversion White Paper Available on MSL

Additional query words: object single byte currency date int


Keywords          : 
Version           : 97
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 16, 1999