ACC2000: Data Type of Value Overrides Data Type of Variable

ID: Q210549


The information in this article applies to:

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


SYMPTOMS

Microsoft Access internally converts values with implicit data type definitions before assigning those values to variables. This may result in unexpected rounding of numbers, or in the following error message:

Invalid Number


MORE INFORMATION

You can implicitly define the data type of a value by appending a type-declaration character at the end of the value.

To see how this works, follow these steps:

  1. Open a new module.


  2. Add the following line underneath the Option Compare Database line:


  3. 
    Dim v as Currency 
  4. Press ENTER.


  5. On the View menu, click Immediate window.


  6. In the Immediate window, type the following line, and then press ENTER:


  7. 
    v=123456789123.3456789# 
  8. Type the following line, and then press ENTER again.
    
    debug.print v 
    Note that the value of the variable "v" is now 123456789123.346. The number sign (#) implicitly defined the value as a double-precision value. Microsoft Access internally converted the value to that data type before assigning it to the currency variable.


  9. Repeat steps 5 and 6, replacing # with other type-declaration characters (such as the exclamation point (!) or the at sign (@)).


Additional query words: ui misc prb


Keywords          : kbprg kbdta 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 13, 1999