Link to home
Start Free TrialLog in
Avatar of fitaliano
fitalianoFlag for United States of America

asked on

Copy records in a Continuous Form in Access

I have a continuous form in Access 2003 with field1, field2, field3, field4, field5

Is it possible to copy values from one record to multiple records below?

I can paste only one record at the time with standard Access.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
slight correction:

There is a "Duplicate Record" button wizard in Access.
Create a continuous (tabular) form from your table.
Add a button to this form.
When the wizard opens, select: Record operations-->Duplicate Record
*Select the record you wish to copy*
Then click this button to your hearts content to create your: "multiple records below"

JeffCoachman
Here is how using a button on the form:
Private Sub btnCopy_Click()

  Dim rstSource   As DAO.Recordset
  Dim rstInsert   As DAO.Recordset
  Dim fld         As DAO.Field

  Dim intDupe     As Integer
  Dim intDupes    As Integer

  ' Specify the count of duplicates to create.
  intDupes = 7
  
  If Me.NewRecord = True Then Exit Sub
    
  Set rstInsert = Me.RecordsetClone
  Set rstSource = rstInsert.Clone
  With rstSource
    If .RecordCount > 0 Then
      ' Go to the current record.
      .Bookmark = Me.Bookmark
      With rstInsert
        For intDupe = 1 To intDupes
          .AddNew
            For Each fld In rstSource.Fields
              With fld
                If .Attributes And dbAutoIncrField Then
                  ' Skip Autonumber or GUID field.
                Else
                  ' Copy field content.
                  rstInsert.Fields(.Name).Value = .Value
                End If
              End With
            Next
          .Update
        Next
        ' Go to the last new record and sync form.
        .MoveLast
        Me.Bookmark = .Bookmark
        .Close
      End With
    End If
    .Close
  End With
  
  Set rstInsert = Nothing
  Set rstSource = Nothing
  
End Sub

Open in new window

/gustav