Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7983631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:01:05+00:00 2026-06-04T11:01:05+00:00

In MS Access VBA (2007), I’ve written the functions below to convert a DAO

  • 0

In MS Access VBA (2007), I’ve written the functions below to convert a DAO recordset to a disconnected, in-memory ADO recordset. The problem is that I’m having data type conversion problems on the DAO dbDecimal fields. The problem shows up when I try to insert data from the DAO recordset into the newly created ADO recordset. When I get to the column that is type DAO dbDecimal (ADO adNumeric) I get the following error:

Error -2147217887 (80040e21): 
Multiple-step operation generated errors. Check each status value.

I’ve looked and the error happens every time it gets to this column. The data contained in this column is simple numbers such as 25, 44, 60, etc.

As you can see below, I’ve hard-coded my NumericScale and Precision but this doesn’t seem to help anything.

Public Function ConvertDAORStoADORS(ByRef r1 As DAO.Recordset) As ADODb.Recordset

    If Not r1 Is Nothing Then

        Dim ra As ADODb.Recordset
        Set ra = New ADODb.Recordset

        Dim f1 As DAO.Field, fa As ADODb.Field

        For Each f1 In r1.Fields
            Select Case f1.Type
                Case dbText
                    ra.Fields.Append f1.Name, adVarWChar, f1.Size, adFldIsNullable
                Case dbMemo
                    ra.Fields.Append f1.Name, adLongVarWChar, 10000, adFldIsNullable

                'Here's the problematic one
                Case dbDecimal
                    ra.Fields.Append f1.Name, adNumeric, , adFldIsNullable
                    Set fa = ra.Fields(f1.Name)
                    fa.NumericScale = 19
                    fa.Precision = 4

                Case 9, dbLongBinary, dbAttachment, dbComplexByte, dbComplexInteger, dbComplexLong, dbComplexText, dbComplexSingle, dbComplexDouble, dbComplexGUID, dbComplexDecimal
                    'Unsupported types
                Case Else
                    Debug.Print f1.Name & " " & f1.Type
                    ra.Fields.Append f1.Name, GetADOFieldType(f1.Type), , adFldIsNullable

            End Select
        Next f1
        ra.LockType = adLockPessimistic
        ra.Open
        'On Error Resume Next
        If Not (r1.EOF And r1.BOF) Then
            r1.MoveFirst
            Do Until r1.EOF = True
                ra.AddNew
                For Each f1 In r1.Fields
                    'Error -2147217887 (80040e21) Multiple-step operation generated errors. Check each status value.
                    'Error only occurs on dbDecimal/adNumeric fields
                    ra(f1.Name).value = r1(f1.Name).value
                Next f1
                ra.Update
                r1.MoveNext
            Loop
        End If

        Set ConvertDAORStoADORS = ra
    End If

End Function

Private Function GetADOFieldType(daofieldtype As Integer) As Long
    Select Case daofieldtype
        'Fixed width adWChar does not exist
        Case dbText: GetADOFieldType = adVarWChar
        Case dbMemo: GetADOFieldType = adLongVarWChar
        Case dbByte: GetADOFieldType = adUnsignedTinyInt
        Case dbInteger: GetADOFieldType = adSmallInt
        Case dbLong: GetADOFieldType = adInteger
        Case dbSingle: GetADOFieldType = adSingle
        Case dbDouble: GetADOFieldType = adDouble
        Case dbGUID: GetADOFieldType = adGUID
        Case dbDecimal: GetADOFieldType = adNumeric
        Case dbDate: GetADOFieldType = adDate
        Case dbCurrency: GetADOFieldType = adCurrency
        Case dbBoolean: GetADOFieldType = adBoolean
        Case dbLongBinary: GetADOFieldType = adLongVarBinary
        Case dbBinary: GetADOFieldType = adVarBinary
        Case Else: GetADOFieldType = adVarWChar
    End Select
End Function

I am deriving my DAO recordset from an ODBC Linked table which is linked to MS SQL Server 2008. The field is actually a SQL Server Decimal(19,4) data type.

Any ideas how to get around this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:01:07+00:00Added an answer on June 4, 2026 at 11:01 am

    This works for me, but I am not sure why you are not just creating the ADODB recordset from the table and disconnecting it.

      Case dbDecimal
          ra.Fields.Append f1.Name, adDecimal, , adFldIsNullable
          Set fa = ra.Fields(f1.Name)
          fa.NumericScale = 19
          fa.Precision = 4
    

    Also, why not

        Dim ra As New ADODb.Recordset
        ''Set ra = New ADODb.Recordset
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
When a user start an Access 2007 database that have macros and vba, a
How do I execute a saved query in MS Access 2007 in VBA? I
Although I've done VBA projects within a single application for both MS Access 2007
I'm having trouble creating an Access table using VBA, then accessing it via open-recordset.
I've written a few Access db's and used some light VBA, and had an
I wonder why I can't execute this SQL query in access 2007 through VBA,
Using Access 2007 vba addressing an Excel 2007 workbook (WB).... This routine adds a
Can I use access 2007 VBA references with impunity (specifically, as far as the
Are there many differences between Access VBA 2010 and 2007?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.