How can I duplicate records into a table using a form

A

Alf

I want to enter the same record several times using a form and storing these
records into a table. How can I duplicate one record for a number of times,
(say 5 times) at once
 
M

Mark A. Sam

Hello Alf,

Place a button on the form. On tha tag property of each control for the
fields you want to copy, place an identifier such as the word "Copy"
(without the quotes).

In the Click event for the button place this code:


Dim ctl As Control
With Me.RecordsetClone
.AddNew
For Each ctl In Me.Controls
If ctl.Tag = "Copy" Then
.Fields(ctl.Name) = ctl
End If
Next ctl
.Update
.MoveLast
Me.Bookmark = .Bookmark
End With

Each time you click the button, a new record will be created. You will also
be taken to the new record. If you want to stay on the original record,
remove the lines,

.MoveLast
Me.Bookmark = .Bookmark

God Bless,

Mark A. Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top