Automated Paste Append Problem

C

CJM

A colleague is having a problem automating a Paste Append operation.

He tried using the following code:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
Forms![Data Input]![SafetyOff] = "Y"
DoCmd.RunCommand acCmdRecordsGoToNew
Call AllEnable
DoEvents
DoCmd.RunCommand acCmdPasteAppend

But it raised errors (ie put records in a Paste Errors table)

He tried a manual cut & paste which worked.

So then he tried 'automating' the manual operation using Sendkeys, but that
didnt work either.

Any thoughts? I'm not an Access whizz myself so I thought I'd ask you guys.
Let me know if you need more info...

Cheers

Chris
 
M

Mingqing Cheng [MSFT]

Hi CJM,

Nice to see you here!

From your descriptions, I understood that you colleague would like to copy
and paste data records automatically. Have I understood you? If there is
anything I misunderstood, please feel free to let me know. You could also
have you colleague reply in this thread, I would like to be of assistance!

What kind of funcationality does he want to realize? If he would like to
copy all data records
I found Access MVP Sandra Daigle has a good sample here before, I pasted it
below
--------------------------
Here is some sample code that uses the recordsetclone of the form to make a
copy of the current record - note that in this example (built on the
Northwind Employee form), the Employeeid field is an autonum field and is
skipped, also, at least one of the other Unique Key fields is amended with
the string "Copy". This makes the copy stand out, but it also allows you to
save the record without errors on duplicate key values.

Private Sub Command34_Click()
Dim fld As Field
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me.Recordset.AddNew
For Each fld In .Fields
'skip the PK field
If fld.Name <> "EmployeeID" Then
Me.Recordset.Fields(fld.Name) = fld.Value
'amend the value in one of the unique index fields
If fld.Name = "LastName" Then
Me.Recordset.Fields(fld.Name) = fld.Value & " Copy"
End If
End If
Next fld
Me.Recordset.Update
End With
set fld=nothing

End Sub
--------------------------

What's the exact error message Access shows? Would you please give a
detailed descriptions of them? More detailed information, I believe, will
make us closer to the resolution. What's the funcationality you would like
to realize? Is it possible for me to show me a sample?

If you only want to copy and poste data, here is another way to do this by
using API

API: Copy variables/control contents to memory
http://www.mvps.org/access/api/api0049.htm

Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 
C

CJM

Hi Mingqing,

I've just spoken to my colleague - he adapted your code sample, and it
appears to be working fine.

Thanks

Chris
 
M

Mingqing Cheng [MSFT]

Hi Chris,

I am very glad to hear that it is resolved, thanks for posting back!

If you have any questions on Access or SQL Server issues, don't hesitate to
let me know. We are here to be of assistance!

Thanks for using MSDN Managed Newsgroup again!


Sincerely yours,

Mingqing Cheng
Microsoft Developer Community Support
 

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