The following vba code transfers the current record with all fields in MS Access.

A copy of the record is created as a recordsetclone and then the individual fields are transferred directly to the copy in the code.

The advantage is that the field values can be adjusted at runtime.


Record in the form before the copy

Access: Copy Current Record to vba


Record after pasting

Access: Copy Current Record to vba


Vba code

Private Sub fg_Zeile_einfuegen()

    '----------------< fg_Zeile_einfuegen() >----------------


    Dim rec As Recordset

    Set rec = Me.Recordset


    '----< Clone Recordset_Data >----

    Dim recClone As Recordset

    Set recClone = Me.RecordsetClone


    recClone("LfdNr") = rec("LfdNr")

    recClone("LfdNr_SubNr") = "9"

    recClone("ID_Projekt") = rec("ID_Projekt")

    recClone("SchottNr") = rec("SchottNr")

    recClone("Etage") = rec("Etage")

    recClone("Raum") = rec("Raum")

    recClone("FotoNr") = rec("FotoNr")

    recClone("LV_Position") = rec("LV_Position")




    '< bookmark >

    Dim ID As Long

    ID = ID_Position

    '</ bookmark >


    '--</ @Loop: Clone >--

    '----</ Clone Recordset_Data >----


    AllowAdditions = True


    fg_Goto_ID ID


    '----------------</ fg_Zeile_einfuegen() >----------------

End Sub


Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel