422,904 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,904 IT Pros & Developers. It's quick & easy.

VBA- Copy in Access

P: 1
I have been asked to create a copy button in an access form to copy the Data in the fields that users enter so they can paste it in an internal system. I crated button and created VBA code "on the click:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command6_Click()
  2.  On Error GoTo Err_cmdDuplicate_Click
  3.    DoCmd.RunCommand acCmdSelectRecord
  4.     DoCmd.RunCommand acCmdCopy
  6. Exit_cmdDuplicate_Click:
  7.     Exit Sub
  9. Err_cmdDuplicate_Click:
  10.      MsgBox Err.Description
  11.     Resume Exit_cmdDuplicate_Click
  13. End Sub
I am having 2 problems:
it copies all the data with the headers but and it paste it vertically other than horizontally . which I guess it needs to be formatted but I am not sure how since I am not VBA SAVVY. I have to add since the code was grabbing everything in the form even the information that I didn't want to and it looked like a chaos ,I created a query then a report based on the query then made copy button with the code behind it.
I appreciate your help in advance.

Attached Images
File Type: jpg PIC2.jpg (24.4 KB, 18 views)
File Type: jpg PIC3.jpg (42.1 KB, 19 views)
File Type: jpg PIC1.jpg (16.6 KB, 18 views)
1 Days ago #1
Share this Question
Share on Google+
2 Replies

Expert Mod 100+
P: 2,415
If it is only certain fields that you need to copy, then you will ave to write the VBA to select those particular fields and save them separately. The code you posted simply copies the entire record.
1 Days ago #2

Expert Mod 5K+
P: 5,087
the fields that users enter so they can paste it in an internal system
Looks like you are using a word document, is this correct?
If so, take a look at:
home > topics > microsoft access / vba > insights > application automation
The two examples are for Outlook and Excel; however, simple step to do this same thing with Word. Before we can help you do that we would need a bit more information about what you are doing with the information... may be easier to create a report in Access or to link the Word document to the database using the mail-merge if the access-report can't handle something (although, since Access2003 I've been moving more and more of my stuff from external Word merges to internal reports).
1 Days ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.