Microsoft KB Archive/282320

= ACC2002: Error Message: &quot;Run-Time Error. Requested Conversion Is Not Supported&quot; =

Article ID: 282320

Article Last Modified on 11/6/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282320



Advanced: Requires expert coding, interoperability, and multiuser skills.

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



SYMPTOMS
When you use calculated columns that contain data of the Variant data type, you receive the following error message:

Microsoft Visual Basic

Run-time error '-2147217891 (80040e1d)':

Requested conversion is not supported



CAUSE
Access does not use consistent behavior with calculated columns that are based on the Variant data type.



RESOLUTION
Replace variant with non-variant data. In the code example in the &quot;More Information&quot; section of this article, replace the rs(0) = &quot;string&quot; line of code with rs(0) = 5 so that the code looks as follows: Sub ShapeTest ' Dimension connection and recordset objects for this module. Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim rs3 As New Recordset ' Open the connection using the Shape provider. cn.Open &quot;Provider=MSDataShape;Data provider=MSPersist;&quot;

' Append 2 columns to the existing recordset. One column is of Variant ' data type and the other column is of Integer data type. rs.Fields.Append &quot;Col1&quot;, adVariant rs.Fields.Append &quot;Col2&quot;, adInteger

'Open the recordset. Add a new record to the recordset. rs.Open rs.AddNew

' Set the recordset's first column data equal to the Integer value of 5. rs(0) = 5 ' This line changed from rs(0) = &quot;string&quot; (variant data).

' Set the recordset's second column data equal to 1, an Integer value. rs(1) = 1

' If the file exists, delete it. If Dir(&quot;c:\temp\test1.temp&quot;) <> &quot;&quot; Then Kill &quot;c:\temp\test1.temp&quot;

' Save the recordset to the specified file name using ADTG format. rs.Save &quot;c:\temp\test1.temp&quot;, adPersistADTG ' Close the recordset. rs.Close ' Open another recordset and use the Shape provider. Use the previously ' saved file and combine its data with the results of the first column ' multiplied by 2. The &quot;CALC(col1*2)&quot; part of this statement is the ' calculated column. rs2.Open &quot;SHAPE TABLE[c:\temp\test1.temp] APPEND CALC(col1*2)&quot;, cn,, , -1

' In the Immediate window, print the calculated column results. Debug.Print rs2(2) 'errors occurred End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Open the sample project NorthwindCS.adp.  Create a new module, and then type or paste the following code into the module: Sub ShapeTest ' Dimension connection and recordset objects for this module. Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim rs3 As New Recordset

' Open the connection using the Shape provider. cn.Open &quot;Provider=MSDataShape;Data provider=MSPersist;&quot; ' Append 2 columns to the existing recordset. One column is of Variant ' data type and the other column is of Integer datatype. rs.Fields.Append &quot;Col1&quot;, adVariant rs.Fields.Append &quot;Col2&quot;, adInteger 'Open the recordset. Add a new record to the recordset. rs.Open rs.AddNew

' Set the recordset's first column data equal to the character string ' &quot;string&quot;, indicating a Variant data type. rs(0) = &quot;string&quot;

' Set the recordset's second column data equal to 1, an Integer value. rs(1) = 1

' If the file exists, delete it. If Dir(&quot;c:\temp\test1.temp&quot;) <> &quot;&quot; Then Kill &quot;c:\temp\test1.temp&quot;

' Save the recordset to the specified file name using ADTG format. rs.Save &quot;c:\temp\test1.temp&quot;, adPersistADTG ' Close the recordset. rs.Close ' Open another recordset and use the Shape provider. Use the previously ' saved file and combine its data with the results of the first column ' multiplied by 2. The &quot;CALC(col1*2)&quot; part of this statement is the ' calculated column. rs2.Open &quot;SHAPE TABLE[c:\temp\test1.temp] APPEND CALC(col1*2)&quot;, cn,, , -1 ' In the Immediate window, print the calculated column results. Debug.Print rs2(2) 'errors occurred End Sub  Save the module, and then run it. Note that you receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article.

Additional query words: pra variants calc shaped recordsets

Keywords: kberrmsg kbprb KB282320

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.