[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1382
  • Last Modified:

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.
0
fitaliano
Asked:
fitaliano
  • 2
2 Solutions
 
Rey Obrero (Capricorn1)Commented:
use vba codes and append query to copy one record n times.
0
 
Jeffrey CoachmanCommented:
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

Click this button to your hearts content to create your: "multiple records below"

;-)

JeffCoachman
0
 
Jeffrey CoachmanCommented:
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
0
 
Gustav BrockCIOCommented:
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
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now