Copying a record

A

AkAlan

I need to be able to copy a record and then paste most of it as a new record
using a form.
 
M

Marshall Barton

AkAlan said:
I need to be able to copy a record and then paste most of it as a new record
using a form.


The command button wizard will generate a very simple minded
procedure to duplicate the current record on the form. If
that's not sufficient for your needs. post back with more
details about the fields you do and don't want to copy.
 
A

Aron

I don't want to duplicate all fields, I just want to duplicate some fields
and put different data in some fields (like in the date column I want to put
the Date () function) basically I want to make an append query based on my
current record


Marshall Barton said:
The command button wizard will generate a very simple minded
procedure to duplicate the current record on the form. If
that's not sufficient for your needs. post back with more
details about the fields you do and don't want to copy.

--
Marsh
MVP [MS Access]
AkAlan wrote:
I need to be able to copy a record and then paste most of it as a new record
using a form.
 
M

Marshall Barton

Your use of the term "current record" implies that you want
to do this in a bound form. If so, you can use the form's
capabilities to handle the append operation:

With Me.RecordsetClone
.AddNew
!fldA = Me.fldA 'copy some fields
!fldB = Me.fldB
. . .
!fldX = Date 'set some fields
. . .
.Update
Me.Bookmark = .LastModified move form to new record
End With

If you really want to use an Append query, then you'll have
to construct the SQL statement:

Dim strSQL As String
strSQL = "INSERT INTO thetable (fldA,fldB, ..., fldX) " & _
"Values(" & Me.fldA & "," & Me.fldB & "," & _
. . . & "," & Format(Date, "\#m\/d\/yyyy\#") & _
. . . & ")"
CurrentDb.Execute strSQL, dbFailOnError

If any of the fields are type Text or Memo, you have to
concatenate the extra quotes and make sure any internal
quotes are doubled up.
 
Top