Copy Current Record in Visual Basic

Posted on 2006-04-10
Last Modified: 2013-11-25
I'm using Visual Basic as my front end and Access 2000 as my backend.

I want to add a button to a form that would copy the current record.  It would append it to the existing recordset and then show up as the current record.

I'm updating a project and it was done using DAO and datacontrols for the recordsets.  I have to keep it with DAO.

Any help would be appreciated.
Question by:ecohouse
    LVL 16

    Expert Comment

    You can use GetRows to copy the current row to a variant array and then AddNew that to the recordset.  Something like (untested):

        Dim a_Rows As Variant, nFld As Integer
        a_Rows = oRS.GetRows(1)

        For nFld = 0 To UBound(a_Rows, 2)
            a_Rows.Fields(nFld).Value = a_Rows(0, nFld)
        Next nFld

    At least, something like that should work...


    Accepted Solution

    Closed, 125 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now